SCGI, Euphoria, 9,000 requests a second
- Posted by Jeremy Cowgar <jeremy at c?wga?.com> May 06, 2008
- 1237 views
I got SCGI working with EuNet. Here are benchmarks of a Hello World program: ---- CGI: Total transferred: 16620 bytes HTML transferred: 3800 bytes Requests per second: 795.23 [#/sec] (mean) Time per request: 1.258 [ms] (mean) Time per request: 1.258 [ms] (mean, across all concurrent requests) Transfer rate: 127.24 [Kbytes/sec] received ---- SCGI: Total transferred: 159943 bytes HTML transferred: 37278 bytes Requests per second: 8986.74 [#/sec] (mean) Time per request: 0.111 [ms] (mean) Time per request: 0.111 [ms] (mean, across all concurrent requests) Transfer rate: 1401.93 [Kbytes/sec] received ---- Now, here's the good part. This Hello World app is the app that your going to see the least performance increase on! Reason? It's tiny so not much parsing/startup time taken by Euphoria but more than that, once you get involved and have database connections, the CGI app has to connect/disconnect to/from the database every request. Not so with SCGI since it is stateful. So, when the application loads, you connect to the database, you then start listening for connections from the web server. When a connection comes in, you handle it, and then are back at the top of your loop again. No need to connect/disconnect. Oh, also, you can run many independent copies of your SCGI program not only on the same machine, but on multiple machines as it utilizes TCP/IP connections, thus, you can distribute the load, if you are by chance running a 100 million hit per day website So, more on this later, but first, here are the two test programs benchmarked above: ---- hello.cgi
puts(1, "Content-type: text/html\r\n\r\n") puts(1, "<html><body>Hello World!</body></html>")
---- hello.scgi
sequence scgi_server atom sock scgi_server = scgi:new(3015) while 1 do sock = scgi:wait(scgi_server) scgi:puts(sock, "Content-type: text/html\r\n\r\n") scgi:puts(sock, "<html><body>Hello World!</body></html>") end while
-- Jeremy Cowgar http://jeremy.cowgar.com