Question

I am writing now writing some evented code (In python using gevent) and I use the nginx as a web server and I feel both are great. I was told that there is a trade off with events but was unable to see it. Can someone please shed some light?

James

Was it helpful?

Solution

Biggest issue is that without threads, a block for one client will cause a block for all client. For example, if one client requests a resource (file on disk, paged-out memory, etc) that requires the OS to block the requesting process, then all clients will have to wait. A multithreaded server can block just the one client and continue to serve others.

That said, if the above scenario is unlikely (that is, all clients will request the same resources), then event-driven is the way to go.

OTHER TIPS

The only difficulty of evented programming is that you mustn't block, ever. This can be hard to achieve if you use some libraries that were designed with threads in mind. If you don't control these libraries, a fork() + message ipc is the way to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top