Gentoo Archives: gentoo-user

From: Kaddeh <kaddeh@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Web Server Memory Issues
Date: Thu, 13 Jan 2011 00:28:35
Message-Id: AANLkTinm6T92HaJyr1k71RGViX00NbzkfP-G0vWEftaq@mail.gmail.com
In Reply to: Re: [gentoo-user] Web Server Memory Issues by Matthew Summers
1 Matthew,
2
3 Default settings for both my.cnf and httpd.conf are defaults, however, I
4 would assume that a restart of a service would clear up the memory that was
5 used by child processes.
6 The only things that are really different in my.cnf is the base stuff like
7 bin-log and such for doing DB replication.
8 As for the webapp itself, it is PHP, but that is literally to make the MySQL
9 connections to pull down the pages in the database (literally, entire pages
10 of html in columns).
11
12 Cheers
13
14 Kad
15
16 On Wed, Jan 12, 2011 at 4:08 PM, Matthew Summers
17 <quantumsummers@g.o>wrote:
18
19 > On Wed, Jan 12, 2011 at 4:47 PM, Kaddeh <kaddeh@×××××.com> wrote:
20 > > Jarry,
21 > >
22 > > Thanks for the monitoring advice, I am checking out monit right now.
23 > >
24 > > In terms of what is the root cause of the issue, I have narrowed it down
25 > to
26 > > either write caching of a SQL cache issue.
27 > >
28 > > First, addressing the SQL issue and why I think that that could be one of
29 > > the causes. The entire site, for the most part is all in one giant DB
30 > > (~9GB) a significant part of that is a 3gb table full of raw image data
31 > > (yes, I know that this is a REALLY bad idea to do, but I didn't design
32 > the
33 > > site, I just did a migration to off-site) that being said, there could be
34 > a
35 > > problem with that.
36 > >
37 > > The write caching hteroy just comes up because I can clear the cached
38 > memory
39 > > down to 14mb cached using 'sync && echo 3 > /proc/sys/vm/dump_cache'
40 > >
41 > > Cheers
42 > >
43 > > Kad
44 > >
45 > > On Wed, Jan 12, 2011 at 1:37 PM, Jarry <mr.jarry@×××××.com> wrote:
46 > >>
47 > >> On 12. 1. 2011 19:59, Kaddeh wrote:
48 > >>
49 > >>> P4 @ 3.0Ghz
50 > >>> 2GB PC2 4200
51 > >>> 2x 250GB drives in RAID1
52 > >>> The system configurations are default for the most part with the server
53 > >>> running MySQL and Apache.
54 > >>> The problem that I am running into at this point, however is that the
55 > >>> machine seems to run out of memory and will segfault either apache or
56 > >>> mysql when does so, when apache segfaults, it is a recoverable error,
57 > >>> when mysql does it, mysql can't recover short of restarting it.
58 > >>> At this point, I have found a soft fix by running a cron job every 6
59 > >>> hours or so to clear the cached memory, which seems to be the problem,
60 > >>> however, I would like to find a more permanent fix to this issue.
61 > >>
62 > >> First of all, find what is causing that excessive memory usage.
63 > >> I think 2GB should be enough for moderate web with apache+mysql.
64 > >>
65 > >> Second, use some monitoring software. Personally I'm using
66 > >> "monit" and I am very satisfied with it. It can monitor processes
67 > >> (if it is running, answering requests, etc), resources (disk,
68 > >> memory, swap, cpu, i/o), files (content, permissions, checksums),
69 > >> remote hosts (with some basic protocol checks i.e. http, ssh,
70 > >> smtp, ftp, mysql, ntp, dns...), it can inform you about problems
71 > >> (mail, log) and you can define rules what to do in case of anomalies
72 > >> (i.e. if mysql is using to much memory, it will be restarted).
73 > >>
74 > >> It can start/restart processes if they die (happened to me once
75 > >> with sshd on server which was ~50 miles away from me). You can
76 > >> put monit in inittab, so in case monit itself dies it is restarted
77 > >> automatically. Etc, etc.
78 > >>
79 > >> Jarry
80 > >>
81 > >> --
82 > >> _______________________________________________________________
83 > >> This mailbox accepts e-mails only from selected mailing-lists!
84 > >> Everything else is considered to be spam and therefore deleted.
85 > >>
86 > >
87 > >
88 >
89 > So, a few questions:
90 >
91 > What apache MPM are you using? You can control the number of processes
92 > or threads in that file. The default is something like 200 processes
93 > or threads (depending on MPM), so that could cause issues.
94 >
95 > What does your my.cnf look like? MySQL makes it pretty easy to
96 > regulate memory usage in my.cnf.
97 >
98 > What sort of webapp is this, PHP, python, perl, ...?
99 >
100 > That should be a good start.
101 > Cheers
102 > --
103 > Matthew W. Summers
104 >
105 >