Anything but minimal swap use is bad configuration.
You didn't mention whether you have php-apc installed as suggested above. That can help a lot.
I assume you're using putty. Run htop, sort by MEM%, Hide kernel threads, make the putty window as large as possible, go to the window options, Clear Scrollback, Copy All to Clipboard, and paste here. (I wish there were an easier way to output the data that htop provides)
That's the best way I know to view memory use. Then you can see where your 512MB is going.
Please put the output between [ code ] and [ /code ] for readability. Here's an example:
Code:
1 [ 0.0%] Tasks: 40; 1 running
2 [ 0.0%] Load average: 0.00 0.01 0.05
3 [ 0.0%] Mem[|||||||||||||||||||||||||||||||||||||||||||| 138/497MB]
4 [| 0.3%] Swp[||| 21/511MB]
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
2187 mysql 25 5 80336 42592 2820 S 0.0 8.4 20:00.43 /usr/sbin/mysqld
9269 www-data 20 0 134M 33036 25644 S 0.0 6.5 0:08.57 php-fpm: pool www
9268 www-data 20 0 132M 32072 26556 S 0.0 6.3 0:09.65 php-fpm: pool www
9265 www-data 20 0 134M 30540 23604 S 0.0 6.0 0:07.14 php-fpm: pool www
9267 www-data 20 0 132M 30152 24556 S 0.0 5.9 0:08.25 php-fpm: pool www
9263 www-data 20 0 132M 29592 24224 S 0.0 5.8 0:06.95 php-fpm: pool www
9266 www-data 20 0 134M 29528 22536 S 0.0 5.8 0:08.19 php-fpm: pool www
11200 myuser 20 0 8348 6584 1224 S 0.0 1.3 0:00.55 -bash
12721 root 35 15 66404 4636 3080 S 0.0 0.9 0:04.81 collectd -C /etc/collectd/collectd.conf -f
11232 root 20 0 5320 3852 1400 S 0.0 0.8 0:00.33 bash
3869 www-data 20 0 21200 3500 1912 S 0.0 0.7 2:19.93 nginx: worker process
3870 www-data 20 0 21200 3488 1860 S 0.0 0.7 2:12.56 nginx: worker process
3867 www-data 20 0 21336 3376 1876 S 0.0 0.7 2:12.94 nginx: worker process
3868 www-data 20 0 21200 3360 1892 S 0.0 0.7 2:11.71 nginx: worker process
11187 root 20 0 8452 2616 2048 S 0.0 0.5 0:00.10 sshd: myuser [priv]
12982 root 20 0 129M 1864 896 S 0.0 0.4 1:25.01 php-fpm: master process (/etc/php5/fpm/main.conf)
12709 postfix 20 0 5876 1696 1344 S 0.0 0.3 0:00.00 pickup -l -t fifo -u -c
5338 postfix 20 0 6316 1556 1332 S 0.0 0.3 0:00.65 tlsmgr -l -t unix -u -c
11199 myuser 20 0 8560 1436 840 S 0.0 0.3 0:00.44 sshd: myuser@pts/0
12850 root 20 0 2676 1364 1052 R 0.0 0.3 0:02.68 htop
3871 www-data 20 0 20944 1280 712 S 0.0 0.3 0:07.41 nginx: cache manager process
2386 postfix 20 0 6016 1248 1024 S 0.0 0.2 0:01.33 qmgr -l -t fifo -u
3651 root 20 0 20944 1244 800 S 0.0 0.2 0:00.68 nginx: master process /usr/sbin/nginx
2097 root 20 0 5656 1240 1040 S 0.0 0.2 0:00.02 /usr/sbin/sshd -D
2132 syslog 20 0 29528 1196 832 S 0.0 0.2 0:09.56 rsyslogd -c4
2379 root 20 0 5864 1192 1036 S 0.0 0.2 0:06.50 /usr/lib/postfix/master
11231 root 20 0 2656 1116 872 S 0.0 0.2 0:00.00 su
11230 root 20 0 2288 1072 872 S 0.0 0.2 0:00.00 sudo su
1 root 20 0 2920 1056 724 S 0.0 0.2 0:01.12 /sbin/init
2160 root 20 0 2272 636 500 S 0.0 0.1 0:05.46 cron
2244 ntpd 20 0 3512 608 472 S 0.0 0.1 0:02.85 /usr/sbin/ntpd -f /etc/openntpd/ntpd.conf
2243 root 20 0 3620 580 464 S 0.0 0.1 0:00.05 /usr/sbin/ntpd -f /etc/openntpd/ntpd.conf
2425 root 20 0 1872 420 376 S 0.0 0.1 0:00.00 /sbin/getty -8 38400 hvc0
2393 root 35 15 1852 400 344 S 0.0 0.1 0:00.68 /usr/sbin/collectdmon -P /var/run/collectdmon.pid -- -C /etc/collectd/collectd
2208 www-data 20 0 1984 372 332 S 0.0 0.1 0:00.02 /usr/sbin/fcgiwrap
1259 root 18 -2 2552 352 184 S 0.0 0.1 0:00.00 udevd --daemon
1260 root 18 -2 2552 348 184 S 0.0 0.1 0:00.00 udevd --daemon
1038 root 16 -4 2556 332 192 S 0.0 0.1 0:00.13 udevd --daemon
1027 root 20 0 2548 320 212 S 0.0 0.1 0:00.14 upstart-udev-bridge --daemon
1925 root 20 0 2412 188 156 S 0.0 0.0 0:00.00 upstart-socket-bridge --daemon
F1Help F2Setup F3SearchF4InvertF5Tree F6SortByF7Nice -F8Nice +F9Kill F10Quit
From this you can see that the largest piece of memory is used by mysql and the RESident number is about 43MB. I have my.conf tuned so that the query caches and such will only fill it to about that size.
RES is close to actual memory use. Virt is the maximum possible memory that the process might use, but almost never does.
Then you can see that next I have six php-fpm backends and their RES is about 30MB each. However, they also use SHaRed memory of about 23MB each, so really only one is using the full 30MB, the rest are using only about 7MB each. That's APC at work caching the php code in a shared memory space for use by each thread. The rest of the processes only use a few MB each. Kernel is maybe 40MB. Voila, 138MB used out of 497MB total.
How about yours?