user1109846
user1109846

Reputation: 37

Prioritze between http requests with tomcat

I got a webApplication that has two interfaceses. One for configuration and the second is for alerts. How can I prioritize the HTTP requests so the alerts will have higher priority?

I was thinking about adding a connector to tomcat and changing the thread priority but than how do I direct each request to it's servlet?

Thanks

Upvotes: 1

Views: 1516

Answers (2)

Grigory Kislin
Grigory Kislin

Reputation: 17990

What about set thread priority after request received?

 Thread.currentThread().setPriority(Thread.MAX_PRIORITY);

Another point of view - external processing your request with different priority: ex. LOW_PRIORITY or HIGH_PRIORITY in MySql requests.

Upvotes: 0

Brandon
Brandon

Reputation: 10028

Priority seems like a strange concern in a multi-threaded environment. I don't believe there is anything in the servlet spec that would do what you're looking for.

The thread priority seems like the only solution to me. Tomcat allows you to specify the priority of each thread in an executor's thread pool: http://tomcat.apache.org/tomcat-7.0-doc/config/executor.html

You would need to somehow route requests for each interface to the appropriate connector. That would need to be done outside of Tomcat, perhaps with Apache or nginx. If you have a load balancer, that may be an interesting place to do that sort of routing.

You could also give a larger thread pool to the higher priority interface instead of messing with thread priorities. But I'm not quite sure about what you are trying to prioritize.

Upvotes: 1

Related Questions