PDA

View Full Version : slimserver starts 10 daemons?



JoeyC
2007-12-05, 02:20
Heyall.

Sorry if this has come up before, i could not find it on the forums.

I have a problem with SlimServer eating a chunk of memory from the server it's running on. I have 256MB in a server running allsorts (samba, nfs, apache, etc..). When i start the SlimServer memory usage on the system jumps from 94.9MB to 145.4 MB - so a 50MB footprint. Not really a problem now but the server can get busy with above servers and then it can be.

The problem i think lies in the sql backend: it starts 10 processes. Is this necessary? I can't find a configuration option to cut this down to, say, one or two. There are no other processes using MySql.

Anyone any experience with this?

Best,

J

root@foo> fuser -vn tcp 9092
USER PID ACCESS COMMAND
9092/tcp: slimserver 30103 F.... mysqld
slimserver 30104 F.... mysqld
slimserver 30105 F.... mysqld
slimserver 30106 F.... mysqld
slimserver 30107 F.... mysqld
slimserver 30108 F.... mysqld
slimserver 30110 F.... mysqld
slimserver 30111 F.... mysqld
slimserver 30112 F.... mysqld
slimserver 30113 F.... mysqld
slimserver 30116 F.... mysqld

root@foo> uname -a
Linux foo 2.6.22-hardened-r8 #1 Fri Nov 23 14:54:51 CET 2007 i686 Pentium III (Katmai) GenuineIntel GNU/Linux

Ben Sandee
2007-12-05, 07:32
On Dec 5, 2007 3:20 AM, JoeyC <
JoeyC.31437n1196846701 (AT) no-mx (DOT) forums.slimdevices.com> wrote:

>
>
> The problem i think lies in the sql backend: it starts 10 processes. Is
> this necessary? I can't find a configuration option to cut this down to,
> say, one or two. There are no other processes using MySql.


This is a common misconception.

On Linux, when threads are spawned they each show up as a process. All of
those mysql threads (processes) are actually sharing the same memory.

Between 100MB and 200MB is about average for SS+Mysql I would say.
Depending on how much you value your time, $30 on some additional memory
might be worth it (assuming your hardware supports it).

Ben

pfarrell
2007-12-05, 07:45
Ben Sandee wrote:
> Between 100MB and 200MB is about average for SS+Mysql I would say.
> Depending on how much you value your time, $30 on some additional memory
> might be worth it (assuming your hardware supports it).

Just for giggles, I checked memory prices on newegg. They have tons of
512MB kits for about $30 and a fair number of 1GB kits for under $25.

I had no idea memory was so cheap.

--
Pat Farrell
http://www.pfarrell.com/

JoeyC
2007-12-05, 08:11
I thought it would be something in that direction.. still i was hoping to cut things down a bit.
Sever hardware update coming up, i'll stick it out 'till then.

Thanks for the info.

J

ps just out of curiosity, how do i limit them? I don't need 10 threads waiting for things to do..

pfarrell
2007-12-05, 08:19
JoeyC wrote:
> ps just out of curiosity, how do i limit them? I don't need 10 threads
> waiting for things to do..

I don't know and I'm not sure you would want to. MySql is designed as a
multi-thread/multi-process server. If the threads are not doing
anything, they are going to be swapped out very quickly.

There is very little overhead in having processes that do nothing but
wait for something to do.

You might find out more on the dev.mysql.com forums, but I've never
worried about it.

--
Pat Farrell
http://www.pfarrell.com/

snarlydwarf
2007-12-05, 11:33
Actually -all- the threads would have to be idle for them to be swapped out.

Threads share all memory, all open files, everything.

The only difference is the internal CPU registers, which are stored in the process table in the kernel.

You gain maybe a couple hundred bytes in the process table by having one less thread. (And since that is kernel memory and never swapped, who cares... )

pfarrell
2007-12-05, 11:39
snarlydwarf wrote:
> Threads share all memory, all open files, everything.

Threads do, processes don't. I don't know which MySql uses.

> You gain maybe a couple hundred bytes in the process table by having
> one less thread. (And since that is kernel memory and never swapped,
> who cares... )

Even if its a few thousand bytes each, who cares.
Memory is cheap. $30 for 512MB means under $0.30 per megabyte.


--
Pat Farrell
http://www.pfarrell.com/

SuperQ
2007-12-05, 12:02
If you want to tweak the mysql server settings for slimerver, you can play with /var/cache/slimserver/my.cnf

snarlydwarf
2007-12-05, 12:14
Threads do, processes don't. I don't know which MySql uses.

Mysql uses threads. The obvious sign is that the memory usage for all is exactly the same. Processes would show some variation in size.

These are processes:


postfix 30307 0.0 0.3 8764 3996 ? S 11:04 0:00 smtpd -n smtp -t inet -u -o smtpd_sasl_auth_enable yes
postfix 30411 0.0 0.3 8632 3968 ? S 11:04 0:00 smtpd -n smtp -t inet -u -o smtpd_sasl_auth_enable yes
postfix 30417 0.0 0.3 8500 3816 ? S 11:04 0:00 smtpd -n smtp -t inet -u -o smtpd_sasl_auth_enable yes
postfix 31844 0.0 0.3 8632 3828 ? S 11:06 0:00 smtpd -n smtp -t inet -u -o smtpd_sasl_auth_enable yes
postfix 31932 0.0 0.3 8236 3388 ? S 11:06 0:00 smtpd -n smtp -t inet -u -o smtpd_sasl_auth_enable yes
postfix 31935 0.0 0.3 8632 3944 ? S 11:06 0:00 smtpd -n smtp -t inet -u -o smtpd_sasl_auth_enable yes
postfix 32009 0.0 0.3 8500 3764 ? S 11:07 0:00 smtpd -n smtp -t inet -u -o smtpd_sasl_auth_enable yes
postfix 32095 0.0 0.3 8632 3972 ? S 11:07 0:00 smtpd -n smtp -t inet -u -o smtpd_sasl_auth_enable yes


the memory size varies a ton. Mysql, however, doesn't vary a bit in size:



mysql 946 0.0 4.2 84040 10792 ? S Aug21 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
mysql 947 0.0 4.2 84040 10792 ? S Aug21 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
mysql 948 0.0 4.2 84040 10792 ? S Aug21 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
mysql 949 0.0 4.2 84040 10792 ? S Aug21 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock

And those have been running for months, yet all precisely the same size because they are all addressing the exact same memory. Changing a global in one changes it in all of them (the nature of threads which is either a blessing or a curse depending on if you remember the memory is shared).



Even if its a few thousand bytes each, who cares.
Memory is cheap. $30 for 512MB means under $0.30 per megabyte.

True, but at only a couple hundred bytes for a process table entry it is even less to worry about. Let it have two dozen threads and your memory usage wouldn't be any different.

JoeyC
2007-12-05, 15:55
The whole discussion turned a bit academic but interesting none the less. I know now i'm not going to free many flipflops by minimizing the number of threads and that i'm pretty much stuck with the 50MB footprint. But also, just to play around with it is for me a way of getting to know the system and its configuration. Who knows one day i need more threads - now's the time to find out how.

MySql ships with factory defaults, set so it performs reasonably well under most circumstances. MySql is no stranger to a multi-user setup, so i guess an x number of threads makes sense. With (as of yet) only one or two users (Squeezebox, Webinterface) you could do with less. It's not necessary but i'd like to see if i can. Same curiosity that took us to the moon i guess :-)

I had a look at the slimserver my.cnf but i couln't find any documentation about it nor any clue in it as to how to tweak the number of threads.

Thanks for all the imput, guys..

J

pfarrell
2007-12-05, 17:18
I had a look at the slimserver my.cnf but i couln't find any documentation about it nor any clue in it as to how to tweak the number of threads.


http://dev.mysql.com/doc/refman/5.0/en/index.html

pfarrell
2007-12-05, 17:20
Mysql uses threads. The obvious sign is that the memory usage for all is exactly the same. Processes would show some variation in size.


Nice explaination. Thanks