1

i've two small question:

  • What is the difference between EventDriven model and Thread model in handling open connections?
  • How many seconds takes an IOLoop before closing the connection?
pigletfly
  • 1,051
  • 1
  • 16
  • 32
Abdelouahab Pp
  • 4,252
  • 11
  • 42
  • 65

1 Answers1

1
  1. Event driven means a client has requested information and the server will initiate a request. The request is the event. A thread is a process that runs outside the IO thread (ie main thread).

  2. Depends. http://www.tornadoweb.org/documentation/httpserver.html?highlight=keep%20alive#http-server search for "no_keep_alive"

If your asking for how long the browser will sit waiting for the request to finish then I believe indefinitely. So it keeps open until you finish the response. However, I think some browsers may quit on the request and respond with a timeout... but I'm not certain. I just did a test and the browser was still waiting for a finish after 4 minutes and counting.

Steve Peak
  • 2,657
  • 1
  • 17
  • 18
  • so does event-driven wait "forever" and keeps the connection opened! – Abdelouahab Pp Jan 11 '13 at 12:06
  • 1
    It depends on how you handle the request. When you send the command `self.finish()` within a `RequestHandler` then the request is finished and the connection is closed. There is a difference between Requests and Connections. Requests are GET/POST/PUT/DELETE etc. on behalf of the client. A Connection is the socket produced to send the data to the server on behalf of the client. – Steve Peak Jan 11 '13 at 15:13
  • self.finish() is automatic when doing self.redirect() for example? so it's opened until the user jumps to another page? – Abdelouahab Pp Jan 11 '13 at 17:45
  • 1
    Yes. `self.finish()` is automatically called when a redirect happens. To clarify: `self.finish()` call is used to tell Tornado that they can write all the chunks of data back to the client and finish the request. Yes, the connection is alive until the request is finished. – Steve Peak Jan 11 '13 at 18:11
  • ah, so we can say that tornado users should forget the keep alive problem ;) – Abdelouahab Pp Jan 11 '13 at 21:09
  • 1
    It all depends on how you have your system set up. I'm actually working on a method that has both alive and non-alive scenarios playing out. But typically Tornado handles it on its own very well. – Steve Peak Jan 11 '13 at 21:10
  • but, i thought internet of 2013 is a "keep alive" connection! why losing TCP handshakes times and verification when closing the connection? – Abdelouahab Pp Jan 11 '13 at 21:17
  • 1
    Perhaps this can help: http://stackoverflow.com/questions/9334401/http-keep-alive-and-tcp-keep-alive – Steve Peak Jan 11 '13 at 21:35
  • ah! so tornado's keep alive is an http one, not tcp one! – Abdelouahab Pp Jan 11 '13 at 21:53