CGI plugin moving to events
The CGI plugin was initially blocking, because that was the easiest way to write it. This week I’ve so far worked on moving it to the event-based model.
Initial results were terrible, while I could get it stable, its performance was only 50-60% of that of the blocking model, latency was doubled, and it came with 250 more lines of code.
Today, investigating showed that epoll was firing some 2k pointless write events when we had nothing to write. The couple additional syscalls to remove the wait for write events when we know we don’t need them were quite a win.
The latest CGI plugin is event-based, stable, and better than the blocking one, not counting lines of code though (they increased to 300 ;)).
Performance increased 18% for shell scripts, 88% for the C app, and 26% for PHP. Latency is less than half of the blocking model’s one, it’s sub-10ms now (vs 15-20ms).
Transactions/sec:
| Bash | C | PHP | |
|---|---|---|---|
| Blocking | 2.2k | 3.5k | 500 |
| Events | 2.6k | 6.6k | 620 |
For comparison, static pages get 29k on the same setup.
