what is event driven web server

风流意气都作罢 提交于 2019-12-17 15:42:34

问题


I want to understand basics of Event Driven web server, I know one of them is Tornado, but any other information is much appreciated.

Thanks


回答1:


There's a nice analogy of this described here:

http://daverecycles.tumblr.com/post/3104767110/explain-event-driven-web-servers-to-your-grandma




回答2:


A web server needs to handle concurrent connections. There are many ways to do this, some of them are:

  • A process per connection.
  • A process per connection, and have a pool of processes ready to use.
  • A thread per connection.
  • A thread per connection, and have a pool of threads ready to use.
  • A single process, handle every event (accepted connection, data available to read, can write to client, ...) on a callback.
  • Some combination of the above.
  • ...

At the end, the distinction ends up being in how you store each connection state (explicitly in a context structure, implicitly in the stack, implicitly in a continuation, ...) and how you schedule between connections (let the OS scheduler do it, let the OS polling primitives do it, ...).




回答3:


Event-driven manner aims at resolving the C10K Problem. It turns the traditional 'push model' into a 'pull model' to create a non-blocking evented I/O. Simply put, the event-driven architecture avoid spawning additional threads and thread context switching overheads, and usually ends up with better performance and less resource consumption.

Some overview from a rails developer, also includes analogy: http://odysseyonrails.com/articles/8



来源:https://stackoverflow.com/questions/3981566/what-is-event-driven-web-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!