?
Solved

Limit concurent access per module

Posted on 2003-03-11
11
Medium Priority
?
221 Views
Last Modified: 2010-03-04
Hi,

Is there a way to specify a limit on the number of concurrent accesses per module or per handler type?

Maybe I'm talking Windows terms (and sorry for that), but I see that when Apache starts it starts 250 worker threads. I assume this means it can serve up to 250 concurrent requests. That's fine. The problem is that I have a module (say mod_mine) that, when runs, requires some resources. I want Apache to make sure no more than 10 threads are used concurrently to handle requests (by mod_mine), sine each thread that runs mod_mine needs a lot of resources (e.g. a DB connection).

Thanks.
0
Comment
Question by:barakori
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
11 Comments
 
LVL 8

Expert Comment

by:heskyttberg
ID: 8110178
Hi!

Sorry, there is no way of doing this wihtout running multiple instances on diffrent ports.

If you're willing to run a few diffrent apache on diffrent ports and use redirect then this can be done.

Start a new apache with another conf file change port in this conf file. And lower the min/max servers.

In original conf file remove the mod_mine module from loading.

That is the only way of accomplishing this that I know of.

Regards
/Hans - Erik Skyttberg
0
 

Author Comment

by:barakori
ID: 8110256
If there's no way of doing that, is there a way to programatically say (within the module) that I want to enter a wait state, and the module itself will handle the multiple number of concurencies? Of course, I'll hold a worker thread while doing that...
0
 

Author Comment

by:barakori
ID: 8110410
If there's no way of doing that, is there a way to programatically say (within the module) that I want to enter a wait state, and the module itself will handle the multiple number of concurencies? Of course, I'll hold a worker thread while doing that...
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 27

Expert Comment

by:BigRat
ID: 8110917
Whether you access limited resources via a module or ust in cgi the effect is the same, the incomming requests spawn until no more resources. Each Apache instance (and hence each module instance) can serve only one incomming request at a time.

You really should be looking at an App Server solution like TomCat. Incomming requests get packaged up and served to an App Server who has a limited number of threads (concurrent options), or has a limited number of lockable resources (like DB connections).

HTH
0
 
LVL 8

Expert Comment

by:heskyttberg
ID: 8111795
Hi!

Yes, if using a app server you can create a DB connection pool from which all apps get thrier DB connections and free them back to for example. Making it possible for you to only allow 20 connections for example.

You cannot prgoram this into the module.
You have to remember one httpd server process can only serve one process at a time, also remember http is stateless meaning you have no open connection to the client so how would your module count open connections ?

If you have 256 httpd running which all uses the module, only 256 simultaneous connections can be made and hence no more than 265 DB links either.

Regards
/Hans - Erik Skyttberg
0
 

Author Comment

by:barakori
ID: 8112368
The problem is that the resource is not a DB (it was just an example). It's something I wrote in C++, and no one provides pooled access for that. I don't want to use Tomcat or JBoss because of the performance issues and possibly JNI complications. I want my apache to service a lot of requests (e.g. 250 concurrently), but say that it could only serve 10 that are handled by a specific module, because these will require heavy processing. If I don't limit that, and I get more than 10 requests within that module, It will bring the server down to its knees.
0
 
LVL 8

Accepted Solution

by:
heskyttberg earned 500 total points
ID: 8112502
Hi!

Well as I said then you need to do like this.
Create a new httpd.conf

Edit the regular one and remove your module from that httpd.conf.

Reload apache.

Alter the copied httpd.conf and alter theese values:
StartServers 10
MinSpareServers 10
MaxSpareServers 10
MaxServers 10

I'm not 100% sure about the names but something like this.
Change port in this httpd.conf to 2080 or something else clever.

If you are running redhat also copy /etc/init.d/httpd script to like /etc/init.d/httpd.sp_module
Edit that script to point to the new httpd.conf file.

Make a redirection page so any user requesting your module will be redirected to the same URL but port 2080.

This is only way to limit the number of concurrent users to a special module.

Regards
/Hans - Erik Skyttberg
0
 
LVL 27

Assisted Solution

by:BigRat
BigRat earned 500 total points
ID: 8118877
"Make a redirection page so any user requesting your module will be redirected to the same URL but port 2080."

or forward proxy it, so that the second server is not seen outside.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question