Recommended web server for jruby sinatra

Want to leverage java threads within a sinatra app, but i’m not sure
of which web server to use. I would like to avoid building war
files. I have used both glassfish and jetty-rackup and both seem
great thus far. Not sure if the glassfish gem is still being
maintained. Any recommendations?

thx.

-karl


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Of course I recommend Trinidad :slight_smile:

http://github.com/calavera/trinidad

cheers

Wow. So much documentation! Definitely giving this a spin!

Thx

Sent from my iPad

2010/7/21 Karl B. [email protected]:

Wow. So much documentation! Definitely giving this a spin!
Thx

It looks pretty sweet; you should. :slight_smile:

I’m also compelled to add in my contribution, Mizuno:

Multithreaded, and I’ve had it do 10k req/sec on a server class
machine; the benchmark in the README is on my lousy MacBook.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Wow, that looks cool too.

What do you mean by asynchronous requests? Sounds a bit like event
machine.

Integrating with rack::logger is a pretty important one to me. It’s
difficult to figure out what went wrong in the log if you cannot see
log of the request.

thx.

-karl
On Jul 21, 2010, at 6:29 AM, Don W. wrote:

Multithreaded, and I’ve had it do 10k req/sec on a server class
machine; the benchmark in the README is on my lousy MacBook.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Jul 21, 2010 at 11:29 AM, Don W. [email protected] wrote:

Multithreaded, and I’ve had it do 10k req/sec on a server class
machine; the benchmark in the README is on my lousy MacBook.

Anyone aware of any hosting companies that use these options, or let you
use
them?
Thinking more along the lines of the cheaper end of hosting - I have
been
spoiled
by Heroku lately, but an upcoming project is going to need a bit more DB
than their
cheapest packages.

I don’t deploy to J2EE containers much, so I tend to only use JRuby web
containers
for ease of developing on windows, staging environments or isolating
dependencies.

Which is a bit of a waste for options with this kind of performance &
convenience, not to
mention being able to single process everything.

Tried to start using my config.ru a bunch of ways and i got some errors:

^Cpetrushka:email_gateway karl$ trinidad -r config.ru
/Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb:1451:in
complete': invalid option: -r (OptionParser::InvalidOption) from /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb: 1449:in catch’
from /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb:
1449:in complete' from /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb: 1288:in parse_in_order’
from /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb:
1255:in catch' from /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb: 1255:in parse_in_order’
from /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb:
1249:in order!' from /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb: 1340:in permute!’
from /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb:
1361:in parse!' from /Users/karl/.rvm/gems/jruby-1.5.0/gems/calavera-trinidad-0.4.1/ bin/../lib/trinidad/command_line_parser.rb:74:in parse’
from /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/1.8/optparse.rb:
792:in initialize' from /Users/karl/.rvm/gems/jruby-1.5.0/gems/calavera-trinidad-0.4.1/ bin/../lib/trinidad/command_line_parser.rb:17:in new’
from /Users/karl/.rvm/gems/jruby-1.5.0/gems/calavera-trinidad-0.4.1/
bin/…/lib/trinidad/command_line_parser.rb:17:in parse' from /Users/karl/.rvm/gems/jruby-1.5.0/gems/calavera-trinidad-0.4.1/ bin/trinidad:8 from /Users/karl/.rvm/gems/jruby-1.5.0/gems/calavera-trinidad-0.4.1/ bin/trinidad:19:in load’
from /Users/karl/.rvm/gems/jruby-1.5.0/bin/trinidad:19

petrushka:email_gateway karl$ trinidad
Jul 21, 2010 8:06:27 AM org.apache.catalina.core.StandardContext
resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /Users/karl/
NetBeansProjects/email_gateway/public does not exist or is not a
readable directory
at
org
.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:
142)
at
org
.apache
.catalina.core.StandardContext.resourcesStart(StandardContext.java:4012)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
4181)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:
1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:
1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:
443)
at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:
710)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:250)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org
.jruby
.javasupport
.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:499)
at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:359)

thx.

Does Trinidad support integration with rack::logger?

thx.

-karl

2010/7/21 Karl B. [email protected]:

Wow, that looks cool too.

What do you mean by asynchronous requests? Sounds a bit like event machine.

The Java Servlet API 3.0 supports asynchronous requests, and I’ve
incorporated that functionality in Mizuno, courtesy of Jetty being the
more-or-less definition of the cutting edge of Java Servlets.

You can ‘throw :async’ and use ‘async.callback’, just like you can
with Thin, but without needing to use EventMachine, which I’ve had
some rather ugly problems with. Of course, you’ll need something that
you want to do asynchronously, and a scheduler for handling that, but
since this is JRuby you’ve got options.

Since the big thing people want to do with asynchronous requests is
Comet, I’m planning on just bundling in the cometd reference servlet
with some configurable filters and providing a tutorial on linking
that up to a Rack app… but that’s going to be in a bit, because I’m
a bit busy with ‘my company’ and ‘getting ready to move back to the
U.S.’ at the moment.

Integrating with rack::logger is a pretty important one to me. It’s
difficult to figure out what went wrong in the log if you cannot see log of
the request.

Haven’t tried it out, but if it’s standard Rack middleware, it’ll work
just fine


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Karl, that’s a really old version that didn’t support rack yet. The
latest
version of Trinidad is 0.9.2

jruby -S gem install trinidad

cheers

Very interesting. I am working on a rest api that communicates with
POP and IMAP servers to download messages to clients which are
currently resque background processes. In the back of my mind, I have
been feeling that i should be leveraging asynchronous request
processing for this since pop and imap can be unpredictable in their
response time. Just not completely sure how to leverage it.

In regards to integrating with rack::logger, do you think it’s
something that may just work out of box somehow or is their still work
to be done with mizuno?

Also, i tried to run mizuno on my sinatra rack app and i get this:

^Cpetrushka:email_gateway karl$ mizuno --debug
“mizuno”
Exception LoadError' at /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/ 1.8/Win32API.rb:2 - Win32API only supported on win32 Exception LoadError’ at /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/
site_ruby/1.8/rubygems/custom_require.rb:38 - Win32API only supported
on win32
Exception LoadError' at /Users/karl/.rvm/rubies/jruby-1.5.0/lib/ruby/ site_ruby/1.8/rubygems/custom_require.rb:38 - no such file to load -- tilt Exception Gem::LoadError’ at /Users/karl/.rvm/rubies/jruby-1.5.0/lib/
ruby/site_ruby/1.8/rubygems.rb:777 - Could not find RubyGem memcache-
client (>= 1.7.4)

Exception `Gem::LoadError’ at /Users/karl/.rvm/rubies/jruby-1.5.0/lib/
ruby/site_ruby/1.8/rubygems.rb:777 - Could not find RubyGem tzinfo (~>
0.3.12)

Exception `Gem::LoadError’ at /Users/karl/.rvm/rubies/jruby-1.5.0/lib/
ruby/site_ruby/1.8/rubygems.rb:777 - Could not find RubyGem i18n (>=
0.3.3)

Using Java extension for JSON.
org.jruby.compiler.NotCompilableException: JITed method size exceeds
configured max of 10000
at org.jruby.compiler.JITCompiler
$JITClassGenerator.compile(JITCompiler.java:334)
at org.jruby.compiler.JITCompiler
$JITClassGenerator.generate(JITCompiler.java:356)
at org.jruby.util.ClassCache.defineClass(ClassCache.java:123)
at org.jruby.util.ClassCache.cacheClassByKey(ClassCache.java:92)
at
org.jruby.compiler.JITCompiler.jitThresholdReached(JITCompiler.java:139)
at org.jruby.compiler.JITCompiler.jitIsEnabled(JITCompiler.java:101)
at org.jruby.compiler.JITCompiler.tryJIT(JITCompiler.java:81)
at
org
.jruby
.internal
.runtime.methods.DefaultMethod.tryJitReturnMethod(DefaultMethod.java:
131)
at
org
.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:
180)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:319)
at
org
.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:
157)
at
org
.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:
172)
at
ruby.jit.require_F5B9B69B62A1A8EB304B060744C40F783057DECA.rescue_1$RUBY
$__rescue___0(dependencies.rb:156)
at
ruby
.jit
.require_F5B9B69B62A1A8EB304B060744C40F783057DECA
.file(dependencies.rb)
at
ruby
.jit
.require_F5B9B69B62A1A8EB304B060744C40F783057DECA
.file(dependencies.rb)
at
org.jruby.ast.executable.AbstractScript.file(AbstractScript.java:39)
at
org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:
153)
at
org
.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:
172)
at
org
.jruby
.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:309)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:
148)
at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.RootNode.interpret(RootNode.java:129)
at org.jruby.Ruby.loadFile(Ruby.java:2539)

Any ideas?

thx.

-karl
On Jul 21, 2010, at 8:17 AM, Don W. wrote:

You can ‘throw :async’ and use ‘async.callback’, just like you can
U.S.’ at the moment.
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

2010/7/21 Karl B. [email protected]:

Very interesting. I am working on a rest api that communicates with POP and
IMAP servers to download messages to clients which are currently resque
background processes. In the back of my mind, I have been feeling that i
should be leveraging asynchronous request processing for this since pop and
imap can be unpredictable in their response time. Just not completely sure
how to leverage it.

The reactor pattern is your friend, and I believe Netty has IMAP and
POP support.

In regards to integrating with rack::logger, do you think it’s something
that may just work out of box somehow or is their still work to be done with
mizuno?

It’ll need to be set up in your app; Mizuno doesn’t do anything extra
with the logs. I spent some time investigating routing the Logger
defaults through Commons Logging, but it unfortunately uses reflection
to find its ‘logger’, and JRuby objects don’t show up there.

Also, i tried to run mizuno on my sinatra rack app and i get this:

[exception snipped]

Wow, that’s a nasty error; the missing gems aren’t used by Mizuno, and
there’s nothing in there big enough to throw out a JIT error. What
platform and JVM are you using, with what settings?


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I am on OSX and i am using:

petrushka:email_gateway karl$ java -version
java version “1.6.0_17”
Java™ SE Runtime Environment (build 1.6.0_17-b04-248-9M3125)
Java HotSpot™ 64-Bit Server VM (build 14.3-b01-101, mixed mode)
petrushka:email_gateway karl$ jruby -v
jruby 1.5.0 (ruby 1.8.7 patchlevel 249) (2010-05-12 6769999) (Java
HotSpot™ 64-Bit Server VM 1.6.0_17) [x86_64-java]

I was able to get it started by adding jruby.jit.maxsize:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/
java -client -Djruby.jit.maxsize=1000000000 -Djruby.memory.max=500m -
Djruby.stk.max=1024k -Xmx500m -Xss1024k -Djffi.boot.library.path=/
Users/karl/.rvm/rubies/jruby-1.5.0/lib/native/Darwin -
Dfile.encoding=UTF-8 -Xbootclasspath/a:/Users/karl/.rvm/rubies/
jruby-1.5.0/lib/jruby.jar -classpath /Users/karl/.rvm/rubies/
jruby-1.5.0/lib/profile.jar: -Djruby.home=/Users/karl/.rvm/rubies/
jruby-1.5.0 -Djruby.lib=/Users/karl/.rvm/rubies/jruby-1.5.0/lib -
Djruby.script=jruby -Djruby.shell=/bin/sh org.jruby.Main /Users/
karl/.rvm/gems/jruby-1.5.0/bin/rackup config.ru -d

On Jul 21, 2010, at 8:51 AM, Don W. wrote:

completely sure

there’s nothing in there big enough to throw out a JIT error. What
platform and JVM are you using, with what settings?


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I’m not pretty sure. Trinidad doesn’t use any global variable, it bypass
all
calls to jruby-rack so you should use it as you use any other rack
server.
It has the option ‘–env’ that works fine with rails, give it a try just
in
case.

Btw, regarding your previous question, since it uses jruby-rack it
should
handle rack::logger properly.

I’m going to fix the readme.

Thank you

I think i am getting an older version because the directions say to
install calavera-trinidad.

jgem install trinidad
jgem install calavera-trinidad -s http://gems.github.com
Now i am having a problem setting my RACK_ENV to development:
RACK_ENV=development trinidad -r config.ru
Is this correct?
Thanks!
-karl

I tried the --env option but no luck. To get past this for now, i
hardcoded the RACK_ENV variable.

Trinidad started up and i can hit my api, but i don’t see any rack
logs at all.

Any ideas?

thx.

-karl

No ideas, perhaps I forgot to configure something in jruby-rack but I
never
used sinatra for really serious things.

Btw, could you send me an example script to test it? may be it has a
quick
fix.