Mojolicious performance

537 views
Skip to first unread message

hempslayer

unread,
Jul 27, 2010, 4:39:48 PM7/27/10
to Mojolicious
Hello.

I need example, how to use Mojolicious framework in heavy loaded
production environment.
Because, I used Mojolicious generated minimal application with Apache2
+ mod_fastcgi (hardware: quad Xeon, 4GB RAM, etc) on Linux (kernel
2.6.24) and benchmarked it with "ab" (-n1024 -c128).
"ab" reported:
---
Requests per second: 78.03 [#/sec] (mean)
---
Why so low requests rate?

Thanks.

Sebastian Riedel

unread,
Jul 27, 2010, 5:36:39 PM7/27/10
to mojol...@googlegroups.com

That seems unusually slow, on my laptop i can easily get 900+ req/s using just the built in Mojolicous web server.
Normally the web server is pretty much irrelevant for performance and a database backend is the actual bottleneck.
But since you are just using the minimal generated app something has to be broken.

ave you tried the latest version from GitHub yet?

--
Sebastian Riedel
http://labs.kraih.com
http://mojolicious.org
http://twitter.com/kraih

hempslayer

unread,
Jul 28, 2010, 7:54:25 AM7/28/10
to Mojolicious
> are you tried the latest version from GitHub yet?
Yes, I used latest version from GitHub.

With built in Mojolicous web server in "daemon_prefork" mode, "ab"
reported: "Requests per second: 102.30".
In "daemon" mode, "ab" reported: "Requests per second: 97.33".
But with "starman" and "psgi" mode, "ab" reported: "Requests per
second: 121.66".

To low rates for heavy loaded production environment.
What can be wrong with this?

Roland Lammel

unread,
Jul 28, 2010, 8:14:19 AM7/28/10
to mojol...@googlegroups.com
Next steps are to actually find the root cause which could be either
 - Apache
 - mod_fastcgi
 - mojolicous fcgi handler
 - mojolicious itself

I would suggest to start top down.

 - Measure apache performance alone (static html)
 - Try mod_fcgid instead of mod_fastcgi (ensure you are using sockets)
 - if possible try a simple FCI response handler

Measure all the above with ab, to see where the bottleneck is.
As Sebastion said, he is getting higher numbers on his laptop, so it seems there also might be something wrong with your perl itself.

BR

+rl


--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To post to this group, send email to mojol...@googlegroups.com.
To unsubscribe from this group, send email to mojolicious...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mojolicious?hl=en.




--
Roland Lammel
QuikIT - IT Lösungen - flexibel und schnell
Web: http://www.quikit.at
Email: in...@quikit.at

"Enjoy your job, make lots of money, work within the law. Choose any two."

Sebastian Riedel

unread,
Jul 28, 2010, 10:51:47 AM7/28/10
to mojol...@googlegroups.com
> With built in Mojolicous web server in "daemon_prefork" mode, "ab"
> reported: "Requests per second: 102.30".
> In "daemon" mode, "ab" reported: "Requests per second: 97.33".
> But with "starman" and "psgi" mode, "ab" reported: "Requests per
> second: 121.66".

For a hello world app those numbers are way too low, something is not right.
Here's a good test scenario btw. (since you didn't give us details about yours)

% mojolicious generate lite_app
% MOJO_MODE=production ./myapp.pl daemon_prefork --clients 10 --servers 4 --start 4
% ab -c 30 -n 10000 -k http://127.0.0.1:3000/

I would also like to see the log output in development mode, it contains a req/s number for pure web framework activity (leaving out the web server).

Wed Jul 28 16:41:27 2010 debug Mojolicious:157 [1541]: GET / (ApacheBench/2.3).
Wed Jul 28 16:41:27 2010 debug Mojolicious::Plugin::RequestTimer:37 [1541]: 200 OK (0.001350s, 740.741/s).

> To low rates for heavy loaded production environment.
> What can be wrong with this?

That depends very much on what exactly your app does, for example if your app was talking to a database backend those would be very respectable numbers. ;)

Take reddit for example, they handle about 800 req/s during peak hours with 80 servers, thats just 10 req/s per server.
People often mistake mistake micro benchmarks with scalability. (not saying it's the case here, but worth mentioning)

Sebastian Riedel

unread,
Jul 28, 2010, 11:28:39 AM7/28/10
to mojol...@googlegroups.com
One more thing, while Mojolicious is not exactly slow it has not been optimized at all yet.
The main focus so far was usability and stabilty.
There are still many low hanging fruits, everybody is welcome to start profiling and send patches. ;)

hempslayer

unread,
Jul 28, 2010, 12:32:27 PM7/28/10
to Mojolicious
>That depends very much on what exactly your app does, for example if your app was talking to a database backend those would be very respectable numbers. ;)
My application just generated by Mojolicious, without any changes by
me :)

Cut from development.log
---
Wed Jul 28 16:28:56 2010 debug Mojolicious:157 [18763]: GET /
(ApacheBench/2.3).
Wed Jul 28 16:28:56 2010 debug Mojolicious::Plugin::RequestTimer:37
[19058]: 200 OK (0.415387s, 2.407/s).
Wed Jul 28 16:28:56 2010 debug MojoX::Dispatcher::Routes:128 [18763]:
Dispatching controller.
---

When I commented line, where setting environment variable
"$ENV{MOJO_APP} ||= 'TestApp';",
"ab" reported: "Requests per second: 2135.94" in "daemon_prefork"
mode.
Problem in routes?

Sebastian Riedel

unread,
Jul 28, 2010, 2:56:55 PM7/28/10
to mojol...@googlegroups.com
> Wed Jul 28 16:28:56 2010 debug Mojolicious:157 [18763]: GET /
> (ApacheBench/2.3).
> Wed Jul 28 16:28:56 2010 debug Mojolicious::Plugin::RequestTimer:37
> [19058]: 200 OK (0.415387s, 2.407/s).
> Wed Jul 28 16:28:56 2010 debug MojoX::Dispatcher::Routes:128 [18763]:
> Dispatching controller.

Log messages are more helpful if they are from the same process.
But 2 req/s points at a problem on the framework layer.

> When I commented line, where setting environment variable
> "$ENV{MOJO_APP} ||= 'TestApp';",
> "ab" reported: "Requests per second: 2135.94" in "daemon_prefork"
> mode.

Ok, that would use Mojo::HelloWorld instead of the generated application, so the problem is somewhere inside Mojolicious.

> Problem in routes?

There is nothing platform specific in routes, it could be pretty much everywhere.

Ilya Skorik

unread,
Jul 29, 2010, 3:59:46 AM7/29/10
to mojol...@googlegroups.com
I had problems with performance when I did connection to a Postgresql on each inquiry through DBD::Pg. For me quitted about 70 queries in a second on Core i5 750/4 GB RAM. After I have use DBIx::Connector speed of processing have increased to 250-270 queries in a second.


2010/7/28 Sebastian Riedel <kra...@googlemail.com>
--

Vick Khera

unread,
Jul 29, 2010, 2:16:32 PM7/29/10
to mojol...@googlegroups.com
On Thu, Jul 29, 2010 at 3:59 AM, Ilya Skorik <ilya....@gmail.com> wrote:
> I had problems with performance when I did connection to a Postgresql on
> each inquiry through DBD::Pg. For me quitted about 70 queries in a second on
> Core i5 750/4 GB RAM. After I have use DBIx::Connector speed of processing
> have increased to 250-270 queries in a second.
>

Most databases will incur a heavy cost to re-open the connection every
time. Nobody concerned with performance will run without some sort of
DB connection cache which can hand out connections quickly.

Reply all
Reply to author
Forward
0 new messages