TomcatExpert

NIO implementation of the AJP connector

posted by mthomas on June 17, 2011 10:20 AM

The Apache JServ Protocol (AJP) , is a binary protocol that can proxy inbound requests from a webserver, such as Apache HTTPD, to an application server like Apache Tomcat. Typically used in load balanced web applications where the web server has to pass requests to multiple application servers, using modules like mod_proxy_ajp help improve the speed of transactions and add support for SSL. This week’s update of Apache Tomcat 7.0.16, introduces a NIO implementation of the built-in AJP connector.

What is NIO?

New I/O, usually shortened to NIO, is a set of Java APIs that allow for more scaleable I/O operations. Among other things, NIO provides support for non-blocking of data connections which ensures a response from the application server. Without NIO, admins must configure their web servers and application servers to match the number of threads between the web server and application server. Depending on configuration, application behavior and the number of concurrent sessions, there is a constant risk of running out of threads and having users get a HTTP 500 Internal Server error. NIO eliminates this risk by providing a more efficient usage of these threads.

A Simple Example

In simple deployments, users will have one HTTPD instance and one Tomcat server to host their web application. Configure both to use 1000 threads, and the web server instance and the application server instance should run fine. Where it gets complicated is when you employ multiple HTTPDs and multiple instances of Tomcat, and those instances are not using a 1 to 1 mapping— i.e. situations where any HTTPD instance can talk to any Tomcat instance.

Let’s say that you have 2 HTTPD instances and 2 Tomcat instances. Each HTTPD is configured for 1000 threads. Each Tomcat will need to be available to process a connection from each of the threads from all of the instances of HTTPD. So each Tomcat will need 2000 threads. As we add more, this quickly does not scale. As the number of HTTPD instances go up, you need more and more threads on the Tomcat side and eventually this becomes unsustainable.

The NIO Implementation

To avoid running out of threads, admins can work to time out threads, or deploy the Apache MPM Worker to use a pool of threads to reduce the number of connections you will need between HTTPD and Tomcat. Both of these options require significant time and effort to tune the application so it performs well and does not create long running requests or worse, serve up the dreaded 500 Internal Server Error.

The NIO implementation of the AJP connector uses non-blocking I/O on the Tomcat side. So, rather than having one thread per connection, there is a small number of poller threads (normally one or two, and usually under ten) that maintain the connections between Apache HTTPD and Tomcat. Each poller thread can maintain many connections. These poller threads watch for incoming requests from HTTPD and when a request is received , the poller thread passes the request to a worker thread. Once the worker thread completes its task, the worker thread is free to handle another request while the poller thread maintains the connection to httpd. In this scenario, rather than Tomcat having one thread per httpd connection, you can have one thread per concurrent request processed by Tomcat (plus a safety margin) which is often several orders of magnitude lower.

NIO vs APR/Native Connector

Prior to the NIO implementation of the AJP connector, which is pure Java, there was another option for a non-blocking connector through the APR/Native connector. The challenge with the APR/Native implementation is that the code needs to be compiled for every platform. Users need to compile the code for every platform they have throughout their infrastructure. Depending on the size of your architecture, this can get to be an enormous task. Since the NIO implementation is pure Java, there is no need to compile, it just works.

For some deployments, the APR/Native connector may still be worth the extra work of compiling as it does provide better performance for SSL.

Benefits

In recent years, a reasonable number of SpringSource’s support calls come in about configuring Tomcat and HTTPD to ensure that there are always threads available to serve any given request. This new NIO implementation of AJP provides users with a new option that will simplify configuration, tuning and improve performance for deployments where there are multiple instances of HTTPD as well as multiple instances of Tomcat. This will be particularly true where there are multiple platform types involved as it will simplify the setup of this type of non-blocking connector.

Mark Thomas is a Senior Software Engineer for the SpringSource Division of VMware, Inc. (NYSE: VMW). Mark has been using and developing Tomcat for over six years. He first got involved in the development of Tomcat when he needed better control over the SSL configuration than was available at the time. After fixing that first bug, he started working his way through the remaining Tomcat bugs and is still going. Along the way Mark has become a Tomcat committer and PMC member, volunteered to be the Tomcat 4 & 7 release manager, created the Tomcat security pages, become a member of the ASF and joined the Apache Security Committee. He also helps maintain the ASF's Bugzilla instances. Mark has a MEng in Electronic and Electrical Engineering from the University of Birmingham, United Kingdom.

Comments

So the NIO is a more

So the NIO is a more efficient way to manage connections between HTTPD and Tomcat. With it you can work with fewer connections, but it is kind of hard to set up. But it makes it so there’s always threads available to serve a new request.

companies that need IT services

OBAT HERBAL ALAMI GROSIR AMAZON PLUS

Obat Tradisional Kista Ovarium
Obat Alami Kista Amazon Plus terbuat dari sari kulit buah manggis yang kita tahu banyak manfaatnya. Amazon Plus memiliki zat xanthone yang memiliki super anti oksidan berkali-kali ganda dibandingkan dengan jenis buah lainnya.

Obat Sakit Jantung Bengkak Tradisional
Sakit Jantung Bengkak, menyerang pada jantung itu sendiri. Jantung yang terserang penyakit ini kebanyakan dikarnakan adanya penyumbatan di dalam pembuluh darah pada jantung menyebabkan jantung mengalami pembengkakan, secara tidak normal, menyebabkan kekuatan jantung untuk memompa darah menjadi lemah.
Amazon Minuman Kesehatan adalah jus kulit manggis yang merupakan obat tradisional jantung bengkak yang sangat aman & tidak berbahaya untuk kesehatan organ tubuh lainnya.

Obat Hipertensi Paling Ampuh
Obat Tradisional Darah Tinggi Amazon Plus yang terbuat dari sari kulit manggis, madu serta rosella sangat aman jika diminum dan tidak ada efek samping serta tidak terbuat dari bahan-bahan kimia ataupun pengawet. Dikarenakan dalam kulit manggis itu sendiri sudah terdapat bahan pengawet asli.

easy going

Game Hack

pixel gun 3d hack Interestingly you write, I will address you'll find exciting and interesting things on similar topics. clash of clans triche

Good information. Lucky me I

Good information. Lucky me I found your website by accident (stumbleupon). I have bookmarked it for later!
Mortgage Broker Calgary

great offer

The big advantage of using this binary system is available to get any suggestion when it needs to correct. The www.bigbangdissertation.com is helping the software developers to get connected with each other. Without sharing knowledge and information, it becomes hard to solve the problems.

Articles exhibits the

Articles exhibits the certified virtuoso and viable of one's mind or fitness. niceessays.org is the colossal business site which shows to you how you have to make the best piece out of substance on your composition.

Great

Apache Tomcat is now one of the established brands for it's regular users Memorial Day 2016 in Las Vegas

msry

صور

صور حزينه

نكت65

msry

صور

صور حزينه

نكت657

It explains NIO and its

It explains NIO and its implementation by using good example. The article describes the role of Apache JServ protocol in transferring requests from web server to application server. Dissertation writing service reviews opens a platform for web developers to share their knowledge.

Pretty good post. I just

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info moonworlds.com reviews.

By freelancing SEO perform

By freelancing SEO perform overseas, SEO organizations can often charge higher quantities in-line with local expenses and then get the task done overseas for a small fraction of the cost use this link.

Mike Craig

Very useful content on very nice website. Great example of perfection.

NIO are mainly used for more

NIO are mainly used for more scalable I/O operations and also for non-blocking of data connections. Implementing NIO is a very difficult task and I don’t know much about this but after reading your article I got a complete idea about this. product photo editing

chalkboard pens

I think that you could do with some pics to drive the message home a bit, but other than that, this is great blog. A great read. chalkboard pens

whiteboard pens

Hey There. I found your blog using msn. This is a very well written article. I’ll be sure to bookmark it and come back to read more of your useful info. Thanks for the post. I’ll definitely return. whiteboard pens

This post helped me to know

This post helped me to know more about NIO which is the set of Java APIs used to allow more scalable I/O operations. The example that you given about NIO implementation helped to understand more about it. Keep sharing cheap wedding planners

vacuum storage bags

This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck. vacuum storage bags

download full hd movies

thanks for sharing this article

latest hollywood movies
download full hd movies
the magnificent seven download full hd movie
rings movie download full hd
download arrival 2016 full hd movie

good night messages

car tracker

Thanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. car tracker

visit

I really enjoyed reading this post, big fan. Keep up the good work and please tell me when can you publish more articles or where can I read more on the subject? visit

connecter

As the part of study read an article about HTTP Connectors. This is a HTTP connector networking wold have more important here.Connector component that communicates with a web connector via the AJP protocol. Get information from Dissertation writing service

Source

I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job! Source

wild selfies

I'm certainly very happy to read this blog site posts which carries plenty of helpful data, thanks for providing such information. wild selfies

sportagen xt review

Particular interviews furnish firsthand message on mart size, industry trends, ontogeny trends, capitalist landscape and outlook, etc. sportagen xt review

click here to login

This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info: click here to login

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.