Subject: | CPU pinned at 100% with POE::Component::Server::TCP and SSLify |
Date: | Sat, 26 Apr 2014 09:20:45 -0700 |
To: | bug-POE [...] rt.cpan.org |
From: | Joseph Huckaby <jhuckaby [...] gmail.com> |
Hey POE Team,
I believe I have found a bug using POE::Component::Server::TCP and SSLify. I have a very simple HTTPS web server (created using the cookbook example), which does nothing except serve up 300K of plain text for every incoming HTTPS GET request. This works fine until it receives multiple requests at once. Then it shoots up to 100% CPU and stays there indefinitely, long after the requests have completed.
Here is a snapshot of "top" on my server after sending in 10 simultaneous requests and allowing them to complete fully:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1365 root 20 0 191m 20m 4168 R 99.9 0.6 0:10.95 perl
The CPU stays at or around 99.9% indefinitely (I have witnessed several days at least). Also, something to note, even after the CPU is pinned at 100%, the server still accepts new incoming connections, and serves them.
Here is a ZIP file containing my script and sample SSL cert:
https://dl.dropboxusercontent.com/u/201533/poe-tcp-sslify-bug.zip
Here are links to the individual files:
https://dl.dropboxusercontent.com/u/201533/poe-tcp-sslify-bug/server.pl
https://dl.dropboxusercontent.com/u/201533/poe-tcp-sslify-bug/ssl.crt
https://dl.dropboxusercontent.com/u/201533/poe-tcp-sslify-bug/ssl.key
I can reproduce the issue every time by sending in 10 simultaneous HTTPS GET requests from a shell script such as this:
#!/bin/sh
# Fetch URL 10 times simultaneously
curl --insecure "$1" >/dev/null 2>&1 &
curl --insecure "$1" >/dev/null 2>&1 &
curl --insecure "$1" >/dev/null 2>&1 &
curl --insecure "$1" >/dev/null 2>&1 &
curl --insecure "$1" >/dev/null 2>&1 &
curl --insecure "$1" >/dev/null 2>&1 &
curl --insecure "$1" >/dev/null 2>&1 &
curl --insecure "$1" >/dev/null 2>&1 &
curl --insecure "$1" >/dev/null 2>&1 &
curl --insecure "$1" >/dev/null 2>&1 &
The --insecure flag is to prevent curl from validating the cert (which is self-signed).
I am running:
POE version 1.358
POE::Component::SSLify version 1.008
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
Linux pvp.effectgames.com 3.4.82-69.112.amzn1.x86_64 #1 SMP Mon Feb 24 16:31:21 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
openssl-perl-1.0.1g-1.69.amzn1.x86_64
openssl-1.0.1g-1.69.amzn1.x86_64
Other Notes: I cannot reproduce this without SSLify. Meaning, if I strip out all the SSL code and just run a plain HTTP server, everything works fine. Also note that I cannot seem to reproduce this on my local OS X machine hitting localhost, although I suspect that is because localhost is a virtual interface, and all the requests complete "instantly". This bug seems to require a slower network (DSL to Amazon EC2 for example) to occur.
If there is anything else you'd like me to try, please let me know. My server is at your disposal!
Thanks for your time!
- Joe