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.


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.


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 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

thanks for j sharing with

thanks for j sharing with that awesome articles thanks u a lot
rasoio elettrico | regolabarba | ferro da stiro con caldaia | Friggitrice ad Aria | scopa a vapore | ripetitore wifi | ripetitore wifi amplificatore wifi piastra a vapore | miglior aspirapolvere | skateboard elettrico | passeggino leggero | miglior smartphone | tablet per bambini tyuh

You’ve got some interesting

You’ve got some interesting points in this article. I would have never considered any of these if I didn’t come across this. Thanks!. Free SoundCloud Followers

Thanks for sharing this

Thanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people.. certified financial advisor whittier

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

Very awesome!!! When I seek

Very awesome!!! When I seek for this I found this website at the top of all blogs in search engine. wordpress site

Thanks for the wonderful

Thanks for the wonderful post, The content Which you mention in your article ITS really awesome. Its really helpful for everyone. youth prescription sports glasses

I love reading a post that

I love reading a post that will make people think. Also, thank you for allowing me to comment! wordpress designer india

i like your post and all you

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. indian generic drugstore online

Great piece of writing. This

Great piece of writing. This is a real article. This shows that the writer has skills and has the composer to use those skills well and write a phenomenal article. Wonderful work. Keep it up pressure washing service

Well thanks for posting such

Well thanks for posting such an outstanding idea. I like this blog & I like the topic and thinking of making it right. hvac company

This is great, you are good,

This is great, you are good, i like your post and i still waiting our next post! screened pool enclosures

Excellent website combined

Excellent website combined with outstanding top quality products and also I’m positive this will be tremendously beneficial. Legacy Law

After a while helpings

After a while helpings dimensions as well as the very best options to create with dining establishments or perhaps in your own home can become second nature.Web design tampa

I am very happy to read this.

I am very happy to read this. This blog was really an awesome site which I had never found it anywhere, keep post.Manual Lymphatic Drainage

I believe there are many more

I believe there are many more pleasurable opportunities ahead for many peoples that looked at your article.CNC Tax Program

Nice blog and absolutely

Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best.

Through this post, I know

Through this post, I know that your good knowledge in playing with all the pieces was very helpful.nice price generic pharmacy

Its just incredible how much

Its just incredible how much you can take away from something simply because of how visually beautiful it is. home building companies

Nice article, thanks for the

Nice article, thanks for the information. It's very complete information. I will bookmark for next reference. fibromyalgia specialist

Really impressive post. I

Really impressive post. I read it whole and going to share it with my social circules. I enjoyed your article and planning to rewrite it on my own blog. Insurance Brandon FL

A debt of gratitude is in

A debt of gratitude is in order for a magnificent offer. Your article has demonstrated your diligent work and experience you have in this field. Splendid .i cherish it perusing. traslochi Locarno

Nice post! This is a very

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. fashion online shop topmediamarkt

I found your this post while

I found your this post while searching for some related information on blog search...stump grinding in gainesville fl

Extraordinary post, you have

Extraordinary post, you have called attention to some phenomenal focuses , I similarly think this s an exceptionally brilliant site. generic online pharmacy drugs

I read this article. I think

I read this article. I think You put a great deal of exertion to make this article. I like your work. generic online pharmacy

Fine site and the great level

Fine site and the great level of quality information plus I’m convinced this is considerably handy.receding hairline meme

I agree with your blog and i

I agree with your blog and i will be back to check it more in the future so please keep up your work. michael kors outleti love your content & the way that you write.generic pharmacy reliable pills

Congratulation for the great

Congratulation for the great post. Those who come to read your Information will find lots of helpful and informative tips.
mail-order generic pharmacy

Thanks for sharing this

Thanks for sharing this awesome piece of info. It is really very helpful. Pinterest

Positive site, where did u

Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. Cheap Bowling balls for Sale

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

i am impressed from this

i am impressed from this post....the person who create this post it was a great human.. voyante par telephone

This is my first time i visit

This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, insulation contractors edmonton

I’m excited to uncover this

I’m excited to uncover this page. I need to to thank you for ones time for this particularly fantastic read!! I definitely really liked every part of it and i also have you saved to fav to look at new information in your site. opensyd

I got so involved in this

I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.Capital One Sign In

Really appreciate this

Really appreciate this wonderful post that you have provided for us.Great site and a great topic as well i really get amazed to read this. Its really good.Ac repair

Good post! Your post is an

Good post! Your post is an excellent example of why I keep comming back to read your excellent quality content that is forever updated. Thank you!air conditioner repair

great offer

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

I was very impressed by this

I was very impressed by this post, this site has always been pleasant news Thank you very much for such an interesting post, and I meet them more often then I visited this site. Cricket SIM unlock code

i read a considerable measure

i read a considerable measure of stuff and i found that the method for composing to clearifing that precisely need to say was great so i am inspired and ilike to come back again in future.. self balancing scooters

I feel happy to read this

I feel happy to read this post. This is the kind of manual that needs to be given at the blogs. Thanks for sharing information on this topic.running health tips

Fantastic blog page with all

Fantastic blog page with all the terrific good items not to mention I’m absolutely sure this will be vastly advantageous. best wireless routers 2017

Thanks for writing such a

Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing...voyance par telephone

Thanks a lot for the post. It

Thanks a lot for the post. It has helped me get some nice ideas. I hope I will see some really good result soon. Cosmetic dentist in Beverly Hills

Articles exhibits the

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

Professional and passionate

Professional and passionate language converters and interpreters are at your ease. check out the link hereFree content directory

This substance is composed

This substance is composed exceptionally well. Your utilization of organizing when mentioning your focuses makes your objective facts clear and straightforward. Much obliged to garcinia cambogia buy

It help me very much to solve

It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. I think it may be help all of you. Thanks a lot for enjoying this beauty blog with me.slip resistance test

Post new comment

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