LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-28-2002, 02:55 PM   #1
eva2000
LQ Newbie
 
Registered: Oct 2001
Location: Brisbane, Australia
Posts: 4

Rep: Reputation: 0
Question open file limits in 2.4 kernel/apache?


i hope you can help me out I'm a bit confused after reading about linux's open file descriptor limits at http://mysql.he.net/doc/L/i/Linux.html

so mysql's max concurrent connections is limited up to the OS imposed limits as well as Apache limits ?

2.2.x kernel had default open file descriptor limits at 1024

from the above http://mysql.he.net/doc/L/i/Linux.html it says 2.4.x kernel did away with that limit

but on RH 7.3 with 2.4.18-5 kernel typing in shell as root user

ulimit -a
ulimit -aS
ulimit -aH

shows that open files = 1024 still

ulimit -a
Code:
core file size        (blocks, -c) 0
data seg size         (kbytes, -d) unlimited
file size             (blocks, -f) unlimited
max locked memory     (kbytes, -l) unlimited
max memory size       (kbytes, -m) unlimited
open files                    (-n) 1024
pipe size          (512 bytes, -p) 8
stack size            (kbytes, -s) 8192
cpu time             (seconds, -t) unlimited
max user processes            (-u) 7168
virtual memory        (kbytes, -v) unlimited
ulimit -aS
Code:
core file size        (blocks, -c) 0
data seg size         (kbytes, -d) unlimited
file size             (blocks, -f) unlimited
max locked memory     (kbytes, -l) unlimited
max memory size       (kbytes, -m) unlimited
open files                    (-n) 1024
pipe size          (512 bytes, -p) 8
stack size            (kbytes, -s) 8192
cpu time             (seconds, -t) unlimited
max user processes            (-u) 7168
virtual memory        (kbytes, -v) unlimited
ulimit -aH
Code:
core file size        (blocks, -c) unlimited
data seg size         (kbytes, -d) unlimited
file size             (blocks, -f) unlimited
max locked memory     (kbytes, -l) unlimited
max memory size       (kbytes, -m) unlimited
open files                    (-n) 1024
pipe size          (512 bytes, -p) 8
stack size            (kbytes, -s) unlimited
cpu time             (seconds, -t) unlimited
max user processes            (-u) 7168
virtual memory        (kbytes, -v) unlimited
a friend said that although 2.4.x kernel removed that limitation, apache can still impose it's own open files limit and for me to get around that in Apache 1.3.26 to

edit apache's start up script apachectl and change the line

ulimit -n 1024

to

ulimit -n 2048

however i have 2 apacectl files

/usr/local/apache/bin/apachectl
/usr/sbin/apachectl

but the line ulimit -n 1024 was only found in

/etc/rc.d/init.d/httpd

which is what i normally use to stop and start apache

Now i've restarted apache, logged out and logged back in and the open files via ulimit -a commands still shows 1024 open files ?

what am i doing wrong or missing ?

thanks
 
Old 07-28-2002, 03:30 PM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 11,957

Rep: Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113
When you type ulimit -a you are getting your resource limits. When you edit /etc/rc.d/init.d/httpd and restart apache you are modifying the limits for the shell that apache starts in. Are you trying to increase the file limit as the result of an eror message? If so what was the error.

--jeremy
 
Old 07-28-2002, 07:00 PM   #3
eva2000
LQ Newbie
 
Registered: Oct 2001
Location: Brisbane, Australia
Posts: 4

Original Poster
Rep: Reputation: 0
trying to figure out how to increase the OS limits for mysql to handle more than 1023/4 concurrent connections as outlined in http://mysql.he.net/doc/L/i/Linux.html
 
Old 07-28-2002, 07:48 PM   #4
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 11,957

Rep: Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113
OK, to do this you are going to have to patch the kernel and probably glibc (specifically linuxthreads). Run the following program to see how many threads you can create now:

Code:
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

#define MAX_THREADS 10000
int i;

void run(void) {
  char c;
  if (i < 10)
    printf("Address of c = %u KB\n", (unsigned int) &c / 1024);
  sleep(60 * 60);
}

int main(int argc, char *argv[]) {
  int rc = 0;
  pthread_t thread[MAX_THREADS];
  printf("Creating threads ...\n");
  for (i = 0; i < MAX_THREADS && rc == 0; i++) {
    rc = pthread_create(&(thread[i]), NULL, (void *) &run, NULL);
    if (rc == 0) {
      pthread_detach(thread[i]);
      if ((i + 1) % 1000 == 0)
        printf("%i threads so far ...\n", i + 1);
    }
    else
      printf("Failed with return code %i creating thread %i.\n",
              rc, i + 1);
  }
  exit(0);
}
We can then take it from there.

--jeremy
 
Old 07-28-2002, 09:21 PM   #5
eva2000
LQ Newbie
 
Registered: Oct 2001
Location: Brisbane, Australia
Posts: 4

Original Poster
Rep: Reputation: 0
thanks... how do i run this.. place it in a file.sh and

./file.sh it ?
 
Old 07-28-2002, 09:39 PM   #6
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 11,957

Rep: Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113Reputation: 3113
Place it in file.c then:
Code:
gcc -lpthread -o file file.c
--jeremy
 
Old 07-29-2002, 12:43 AM   #7
eva2000
LQ Newbie
 
Registered: Oct 2001
Location: Brisbane, Australia
Posts: 4

Original Poster
Rep: Reputation: 0
what should i expect the output to be ?

thanks
 
Old 07-29-2002, 01:07 AM   #8
neo77777
LQ Addict
 
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 56
See when it fails it'll tell you on what thread number it failed
 
Old 07-29-2002, 08:14 PM   #9
rverlander
Member
 
Registered: May 2002
Distribution: A few
Posts: 488

Rep: Reputation: 30
after you do the gcc you have to run ./file
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache 2 can't open file! mesh2005 Linux - Networking 4 10-31-2005 12:55 PM
Quotas and File Size Limits wenberg Slackware 1 12-02-2004 05:40 AM
my apache server try to open the conf file from previous path m_a Linux - Networking 4 08-05-2003 06:30 AM
PHP/Apache 2.0 POST limits merana Linux - Software 1 10-15-2002 10:56 PM
File Size limits ascii2k Linux - General 4 04-15-2002 11:25 AM


All times are GMT -5. The time now is 10:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration