孙鑫mfc学习笔记第十六课
2010-08-24 23:31
260 查看
Java web container use HTTPServlet to serve HTTP request. There are 3 ways to
handle requests:
- Create 1 thread which is used to serve all the HTTP requests. It obvious that
this approach does not scale. It can leverage OS concurrency capability and
multiple CPUs.
- Create 1 thread for every request. If there are too many concurrent requests,
too many threads will be created. With too many threads, a lot of resources
will be spent on context switches.
- Create a pool with a fixed number of threads. This approach can show a
graceful degradation under very heavy loads.
Almost non-trivial web containers use the 3rd approach. I want to make sure that
this assumption is right. So I made some experiments with Tomcat 6. The
experiments results validate the assumption. The toString method of thread to
execute HTTPServlet in Tomcat is like Thread[http-8080-2,5,main]. 8080 is port
number of Tomcat. 2 means HTTP thread ID. It is possible that 5 mains the size
of thread pool.
And it does not hold that a thread is always to serve the requests for the
session. A thread is often used to serve requests from multiple sessions.
handle requests:
- Create 1 thread which is used to serve all the HTTP requests. It obvious that
this approach does not scale. It can leverage OS concurrency capability and
multiple CPUs.
- Create 1 thread for every request. If there are too many concurrent requests,
too many threads will be created. With too many threads, a lot of resources
will be spent on context switches.
- Create a pool with a fixed number of threads. This approach can show a
graceful degradation under very heavy loads.
Almost non-trivial web containers use the 3rd approach. I want to make sure that
this assumption is right. So I made some experiments with Tomcat 6. The
experiments results validate the assumption. The toString method of thread to
execute HTTPServlet in Tomcat is like Thread[http-8080-2,5,main]. 8080 is port
number of Tomcat. 2 means HTTP thread ID. It is possible that 5 mains the size
of thread pool.
And it does not hold that a thread is always to serve the requests for the
session. A thread is often used to serve requests from multiple sessions.
相关文章推荐
- 孙鑫mfc学习笔记第十七课
- 孙鑫VC学习笔记:第十五讲 编写一个基于MFC对话框的聊天程序
- 孙鑫mfc学习笔记第十八课
- MFC - 线程同步与异步套接字 (孙鑫C++第十六讲笔记整理)
- 孙鑫mfc学习笔记第十九课
- [MFC学习笔记]--孙鑫第四课
- 孙鑫VC学习笔记:第十五讲 (四) 编写一个基于MFC对话框的聊天程序
- MFC视频教程(孙鑫)学习笔记1-Windows程序内部运行原理
- 孙鑫mfc学习笔记第四课
- 孙鑫mfc学习笔记第二十课
- 孙鑫mfc学习笔记第五课
- MFC视频教程(孙鑫)学习笔记2-掌握C++
- 孙鑫mfc学习笔记第六课
- 孙鑫mfc学习笔记第七八课
- [MFC学习笔记]--孙鑫第三课
- 孙鑫VC++视频学习笔记之2: MFC程序框架的剖析
- 孙鑫mfc学习笔记第九课
- MFC孙鑫视频学习笔记
- 孙鑫VC++视频学习笔记之3: MFC消息映射机制和绘图DC
- 孙鑫VC学习笔记:第十六讲 利用事件对象实现线程间的同步