📜 ⬆️ ⬇️

Perl vs C in web applications, test results

I have long wanted to check how many more requests can process a C-process, in comparison with a Perl-script.
Checked on a simple script with a single SQL query, in order to avoid the influence of mysql. Web server nginx, used by FastCGI.

Experimental - voting script: accepts id from QUERY_STRING, IP-address from REMOTE_ADDR and adds them with a simple INSERT to the mysql table. A little more about this principle of adding votes, I wrote in Tips & Tricks 2 . Both options were connected to the web server (nginx) via FastCGI via unix socket.

Perl script used CGI :: Fast and DBI. For the C-variant I used the fcgi_stdio library, the tests were performed on my modest VPS with CentOS. Due to the fact that I am not the only one to use the physical server, it turned out to be a small scatter in absolute values, but the relative difference remained very noticeable.

Tested with standard ab -n 1000 -c 10, “Requests per second”, average values:
Perl: 933 queries / second
C: 2896 query / s (3 times more!)
')
I remind you that the tests were repeated several times, the numbers were slightly different, but the difference was always about 3-4 times.

And besides the performance gain, the C-process takes several times less memory. In my case - 3.5 times.

ZY I really wanted to post it in the "Web Development", but apparently, karma did not come out. :) If anyone adds karma - I will be grateful.
In the meantime, posts on similar topics can be read in my blog: http://blog.ugnich.com/

Source: https://habr.com/ru/post/15681/


All Articles