[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Limit concurent access per module

Posted on 2003-03-11
11
Medium Priority
?
222 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
  • 3
  • 3
  • 2
8 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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

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

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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). #…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

612 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