Re: [modwsgi] Mod_wsgi very slow

67 views
Skip to first unread message

Jason Garber

unread,
Sep 19, 2012, 12:43:25 PM9/19/12
to mod...@googlegroups.com
Hello Виталий,

What you are talking about has nothing to do with mod_wsgi.  This is a python issue.  If you are interested in comparing Python vs. PHP for string manipulation speed ... 

1. do it on the command line
2. why are you doing it?

String speed tells such a small part of the story.  If that is your focus, C++ or Java would be a better place to look.

Anyway, mod_wsgi whips the pants off of PHP for performance in a real-world web application.  The reason for this isn't that Python is a "faster" language -- it's because mod_wsgi is FAR more efficient than mod_php (default configurations).  When you start to get into more complex sites, the difference becomes much more apparent.

We have really complex web applications with thousands of active users purring on a single server with barely any load....  And the page response time is as fast as a windows application.

Here is a benchmark I just did on comparable code:

--- Login page delivered via Python+mod_wsgi --- dual core processor 2 gb ram server sata drive ---
Document Length:        3045 bytes
Concurrency Level:      20
Time taken for tests:   4.740 seconds
Complete requests:      5000
Requests per second:    1054.75 [#/sec] (mean)

--- Similar page delivered via PHP -- 8 core server with 16 gb ram 15k sas drives --- .
Document Length:        1885 bytes
Concurrency Level:      20
Time taken for tests:   8.076 seconds
Complete requests:      5000
Requests per second:    619.09 [#/sec] (mean)

Just a note from experience... Performance is very important.  But your real performance issues are going to likely be with your database design (or mis-design), not your HTTP handler.

Thanks!
Jason

On Wed, Sep 19, 2012 at 11:04 AM, Виталий Нефедов <vit...@gmail.com> wrote:
Hi, i start learn python3 and have some problem with execute time.
I testing execute time speed on there methods 

toop
for i in range ( N )
...
a = ''
a += (string + str(i));
...
a = []
a.append(string + str(i))
...
a = StringIO()
a.write(string + str(i))

on N = 100000, i had some results:

STRING 1.0920219421386719

ARRAY 1.1565468311309814
StringIO 1.3690509796142578

it's very .. very slow.

Similar in php, i tested there methods on N = 100000 too:
loop
i < N N++
.......
$a .= $string . $i;
...
$a[] = $string . $i;

And i had some best results, it's really faster:
STRING 0.38697910308838
ARRAY 0.603670835495

i try to configure mod_wsgi and i had there results on defauls settings.
I want get best results in python.

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To view this discussion on the web visit https://groups.google.com/d/msg/modwsgi/-/W1Y6HGpKFzEJ.
To post to this group, send email to mod...@googlegroups.com.
To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.

Виталий Нефедов

unread,
Sep 19, 2012, 2:11:46 PM9/19/12
to mod...@googlegroups.com
Jason, ths for answer.
Hm, you are not understand me.
Of course, it's python issue, but we know, that mod_wsgi has some configuration. I mean, that i have bad configuration of apache + mod_wsgi.
I think, that someone write .. some "it's really slow, reconfigure apache, python with some modes ".
I want get fastest method for text output. For example, output html data.. But now, i see, that it's really slow, and i dont know, how i may optimize it.
Of course, in real web-application 100k text iterations is imposible ) .. however, may be xml modules .. but i'ts different topic


среда, 19 сентября 2012 г., 20:43:27 UTC+4 пользователь Jason Garber написал:

Виталий Нефедов

unread,
Sep 19, 2012, 2:33:22 PM9/19/12
to mod...@googlegroups.com
At now, i run my script in comand line with python 2.7 and got some results:
ARRAY APPEND 0.463161945343
PYTHON CONCAT 0.374883890152
it's faster, than php )) yahoo
But, thought python3, i've got:
ARRAY APPEND 0.9795410633087158
PYTHON CONCAT 0.8521389961242676
...
hm.. why?

среда, 19 сентября 2012 г., 22:11:46 UTC+4 пользователь Виталий Нефедов написал:

Bart

unread,
Sep 28, 2012, 8:14:30 PM9/28/12
to mod...@googlegroups.com
Just wondering - have you read http://www.skymind.com/~ocrow/python_string/ ?

There are other details and tradeoffs, but if you care, it makes more sense to talk about real-world examples than pathological ones :)

Regards,
--Bart

Filipe Cifali

unread,
Oct 1, 2012, 1:43:38 PM10/1/12
to mod...@googlegroups.com
The more you add modules to Apache, the more you slow down him.

You need to use Apache? There are other solutions like gUnicorn, cherokee, that can use python for web too...

Even you can write a simple webserver:

http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python

But for performance, study about caching tools.

You cannot process text every single request in "real-world".

Maybe Varnish can help with your solution.


Ps.:

But, IMHO, your tests are not actually right anway...

2012/9/28 Bart <scar...@gmail.com>

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



--
[]'s

Filipe Cifali Stangler

Graham Dumpleton

unread,
Oct 2, 2012, 12:36:27 AM10/2/12
to mod...@googlegroups.com
On 2 October 2012 02:43, Filipe Cifali <cifali...@gmail.com> wrote:
> The more you add modules to Apache, the more you slow down him.

That isn't really a true statement.

Apache modules only hook into specific phases they need to and all the
code at that level is C code, with modules only doing stuff if they
see they need to as per the configuration. Any overhead they do add
would generally be insignificant in the greater context of everything
else that is happening for each request, including what the primary
request handler does.

You care to explain more the basis for your statement.
Reply all
Reply to author
Forward
0 new messages