http://qs321.pair.com?node_id=487624


in reply to Help prevent a ModPerl application from replacement by Java

ModPerl, Catalyst, Class::DBI, DBD::Oracle, Apache, Template Toolkit and a Session Plugin for Catalyst.
(snip)
For the number-driven monks, Java is answering (on the same machine, while Apache/Perl is not running, and vice-versa for Apache/Perl benchmarking) at 100 queries per minute ratio. With Perl, I don't even hit 27 queries per minute.

Are you actually using mod_perl, or are you running the perl scripts via CGI? Are you pre-loading the modules? How much "ramp-up" time do you allow (mod_perl and java servlets need some time to get up to their maximum speed).

Also: are you using a similar setup in java vs perl. Example questions about the java code: do you use an object-relational mapping system similar to Class::DBI, or are you just pumping out straight JDBC queries? Are you using a complex templating system or pure java servlets? Are you using serialisable sessions? update: do you re-use database connections between requests in both instances (oracle is terribly slow if you don't)

  • Comment on Re: Help prevent a ModPerl application from replacement by Java

Replies are listed 'Best First'.
Re^2: Help prevent a ModPerl application from replacement by Java
by monsieur_champs (Curate) on Aug 30, 2005 at 02:44 UTC

    Fellow Joost

    I'm actually using mod_perl, as Catalyst provides a content handler.

    The Java test was made with just 5 seconds of "ramp-up" time. Perl was running under the same conditions. Is that fair?

    My machine shares the Intel Pentium 4 Processor 2.8 GHz and 512Mb Ram with Oracle (nicely tunned to use less memory as usual) with the Tomcat (only when running Java) or Apache/ModPerl (only when running Perl). I know this is not the best situation, but this is what I have.

    We're using the same machine to run tests, just shutdown the application (Java or Perl) that will not be tested and run tests against the other.

    I don't know a lot about the Java code. I guess its simmilar to the Perl code, but this is only a guess. I'll ask about this to the Java programmer tomorrow moring.

    I don't know about the templating system, also. Maybe just servlets, the java application was made on sunday, only for the benchmarks.

    My Catalyst::Plugin::Session::Flex is trully serializable (and just hold some integers, anyway).

    I choosen to use Apache::DBI to handle the database connections, and load it from my httpd.conf file.

    Guess Java is using just one or two database connections, while I'm forced (not sure about "forced") to use a connection per server process.

    You gave me nice tips on what to look for at the Java code so I can state if this is a fair benchmark. Thank you very much and may the gods bless you!

      The Java test was made with just 5 seconds of "ramp-up" time. Perl was running under the same conditions. Is that fair?
      Depending on your setup, it could take the perl version longer than that to open a connection for every apache sub-process. That would slow things down considerably.

      It's also possible that your apache subprocesses don't handle many requests before they are replaced by fresh ones (which also means opening a new database connection).

Re^2: Help prevent a ModPerl application from replacement by Java
by danmcb (Monk) on Aug 30, 2005 at 13:25 UTC

    be suspicious about Template::Toolkit too. Because it gives you the option of flow control in your templates, I wonder you are getting the full advantages of pre-compiled code that mod_perl should give.

    Try CGI::FastTemplate instead - it's substitutions are pure regex subs, not as powerful, but plenty good enough for many purposes (you have to shift the flow control logic, if you are using it, somewhere into your application where it will get pre-compiled).

    I think that if you are really using mod_perl to full advantage, you will be in a much better situation.

    One problem you have is : are you comparing like with like? You have so many modules in there, if you really want to do a language comparison for raw speed, you should start with a very simple, raw perl app that connects to the db, and it's equivalent in java, compare them, then add layers onto each. Otherwise it is impossible to know what you are measuring.

    http://perl.apache.org/docs/tutorials/tmpl/comparison/comparison.html is well worth a read.
      Template Toolkit is really pretty fast. Since it compiles everything to perl opcodes, it should be about as fast as doing the same operation somewhere else in your code. The only big speed trap with it is using the dot notation to call methods, which will certainly be slower than simple variable lookups. People often do that when using Class::DBI with TT.