This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See =================================
"For a servlet not hosted in a distributed environment (the default), the servlet
container must use only one instance per servlet declaration. However, for a servlet
implementing the SingleThreadModel interface, the servlet container may
instantiate multiple instances to handle a heavy request load and serialize requests
to a particular instance."
Panagiotis Varlagas
Ranch Hand
Posts: 233
posted 14 years ago
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To second Chris' warning about avoiding SingleThreadModel like the plague. Here is a paragraph from an excellent book on perf. tuning.
("Performance Analysis for Java™ Web Sites
By Stacy Joines, Ruth Willenborg, Ken Hygh")
"The servlet specification does provide a single-threaded alternative. By implementing the javax.servlet.http.SingleThreadModel interface, your servlet becomes single-threaded. This means the application server creates an instance of your servlet for each simultaneous request. If you've never written a multi-threaded application before, you might feel tempted to use the single-threaded model. Don't do it! The single-threaded model does not perform well, particularly in high-volume web sites nor does it scale well. In this model, each request operates within its own fully instantiated servlets. This requires more memory and related overhead than the multi-threaded model. While the single-threaded model might seem like a shortcut, it is actually a performance dead end. Take the time and learn how to write good multi-threaded servlets instead."
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!