Servlet Threading Model

The scalability issues of Java servlets are caused mainly by the server threading model:

Thread per connection

The traditional IO model of Java associated a thread with every TCP/IP connection. If you have a few very active threads, this model

can scale to a very high number of requests per second.

However, the traffic profile typical of many web applications is many persistent HTTP connections that are mostly idle while users read

pages or search for the next link to click. With such profiles, the thread-per-connection model can have problems scaling to the

thousands of threads required to support thousands of users on large scale deployments.

Thread per request

The Java NIO libraries support asynchronous IO, so that threads no longer need to be allocated to every connection. When the connection

is idle (between requests), then the connection is added to an NIO select set, which allows one thread to scan many connections for activity.

Only when IO is detected on a connection is a thread allocated to it. However, the servlet 2.5 API model still requires a thread to be

allocated for the duration of the request handling.

This thread-per-request model allows much greater scaling of connections (users) at the expense of a small reduction to maximum requests

per second due to extra scheduling latency.

Asynchronous Request handling

The Jetty Continuation (and the servlet 3.0 asynchronous) API introduce a change in the servlet API that allows a request to be dispatched

multiple times to a servlet. If the servlet does not have the resources required on a dispatch, then the request is suspended (or put into

asynchronous mode), so that the servlet may return from the dispatch without a response being sent. When the waited-for resources

become available, the request is re-dispatched to the servlet, with a new thread, and a response is generated.

Servlet Threading Model的更多相关文章

  1. Memcached source code analysis (threading model)--reference

    Look under the start memcahced threading process memcached multi-threaded mainly by instantiating mu ...

  2. threading模块

    threading — Higher-level threading interface¶ Source code: Lib/threading.py This module constructs h ...

  3. python学习笔记——线程threading (一)

    1 线程threading 1.1 基本概述 也被称为轻量级的进程. 线程是计算机多任务编程的一种方式,可以使用计算机的多核资源. 线程死应用程序中工作的最小单元 1.2 线程特点 (1)进程的创建开 ...

  4. Servlet 介绍

    JSP 的本质就是 Servlet,开发者把编写好的 JSP 页面部署在 Web 容器中后,Web 容器会将 JSP 编译成对应的 Servlet. Servlet 的开发 Servlet 是个特殊的 ...

  5. Threading in C# 5

    Part 5: Parallel Programming In this section, we cover the multithreading APIs new to Framework 4.0 ...

  6. Java Web基础 --- Servlet 综述(理论篇)

    摘要: Web 技术成为当今主流的互联网 Web 应用技术之一,而 Servlet 是 Java Web 技术的核心基础.本文首先从请求/响应架构应用的大背景谈起 Servlet 的由来,明确 Ser ...

  7. Deployment options

    Play applications can be deployed virtually anywhere: inside Servlet containers, as standalone serve ...

  8. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  9. Java---SSH(MVC)面试题

    1.        谈谈你mvc的理解 MVC是Model-View-Controler的简称.即模型-视图-控制器.MVC是一种设计模式,它强制性的把应用程序的输入.处理和输出分开. MVC中的模型 ...

随机推荐

  1. JDK的命令行工具

    Jcmd:综合工具 jcmd -l  列出当前运行的所有虚拟机 参数-l表示列出所有java虚拟机,针对每一个虚拟机,可以使用help命令列出该虚拟机支持的所有命令 jcmd [pid] help j ...

  2. 寒冰王座[HDU1248]

    寒冰王座 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  3. BZOJ1665 : [Usaco2006 Open]The Climbing Wall 攀岩

    直接BFS貌似复杂度飞起来了,于是我们用k-d tree优化找点的过程即可.时间复杂度$O(n\sqrt{n})$. #include<cstdio> #include<algori ...

  4. win8 中实现断点续传

    1) Resume method does resume on cases where resume is possible. Meaning if the server accepts range- ...

  5. APIO2015

    还没有写完APIO2015的题目,打算今天写一写. T1: 按位DP,DP时要保证已确定的位为0. 前4组设f[n][k]表示把前n个分成k组是否合法. 最后一组设g[n]表示把前n个最少分为多少组才 ...

  6. oracle系列--第六篇 Oracle上面小试牛刀

    现在我们可以在oracle上面进行创建表,向表中插入数据,修改表中数据,删除数据,甚至删除表等一系列操作. 即我们所说的CRUD操作. --create a table which name is t ...

  7. jquery 获取input radio/checkbox 的值 【注意写法】

    今天,在用jquery获取页面上radio值的时候,radio给出了默认值,但是无论如何修改值,radio始终是默认值,去掉默认值的时候,页面上又报出了undefined的错误.经过几番搜索,发现不同 ...

  8. FlexSlider插件的详细设置参数

    FlexSlider是一个非常出色的jQuery滑动切换插件,它支持所有主流浏览器,并有淡入淡出效果.适合所有初级和高级网页设计师使用.不过很多人都只是使用默认的参数,今天来说说具体的参数来给大家看看 ...

  9. ITK 4.8.1 Qt 5.4 MinGW 4.9.1 Configuration 配置

    Download ITK 4.8.1 Download Qt 5.4 with MinGW 4.9.1 Download CMake 3.2.0 I assume you've already ins ...

  10. Web移动端设计——移动设备分辨率一览表

    作为在移动端开发的web程序员来说,如果不懂设备的一些性能,在开发上面是非常耗时间的一件事,同时带来负面影响的是项目的进度被拖腿了. 下面是个人收集的一些移动端设备的分辨率参数: 1.  平板设备: ...