On Thu, Nov 17, 2011 at 5:04 AM, Łukasz Mierzwa <l.mier...@gmail.com> wrote: > Dnia czwartek, 17 listopada 2011 11:40:55 Roberto De Ioris pisze: >> Hi everyone, the support for Linux KSM has been added in current mercurial >> tip >> >> http://projects.unbit.it/uwsgi/wiki/KSM >> >> If you host a good amount of uWSGi instances/processes on a recent >> (>=2.6.32) linux kernel, try it. > > This is great feature that all who need to run multiple ruby apps will be > thankful for, but I guess that one should add few zeros at the end of max- > requests value and maybe disable idle option. > The great thing about KSM is that it requires cpu power only to scan/merge > pages, so when under high load one can disable KSM (echo 1 > ksm/run) and all > the saving are still going to be there.
i dont think it's too expensive for KSM to merge pages later on if as they die, so long as your aren't killing stuff off very quickly. slightly OT, but this irritated me for hours -- apparently sysctl only works with /proc/sys? and not /sys?? @#$@#??? no way to apply settings at boot (debian has custom /etc/sysfs.conf, though). systemd (what i use for init) only applies sysctl variables, not sysfs ... so i wrote this: # awk -vs=/sys/ -ve= "!/^\s*(#|$)/{match($0,/^([^=]+)=(.*)$/,a);t(a);print a[2] > s a[1];}function t(a, i){for(i=1;i<3;i++){gsub(/^\s*|\s*$/,e,a[i]);}}" /etc/sysfs.conf ... and as a .service file (modeled from sysctl.service) ----------------------------------------------------- [Unit] Description=Apply Sysfs Variables DefaultDependencies=no Conflicts=shutdown.target After=systemd-readahead-collect.service systemd-readahead-replay.service Before=sysinit.target shutdown.target ConditionPathExists=|/etc/sysfs.conf [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/awk -vs=/sys/ -ve= "!/^\s*(#|$)/{match($0,/^([^=]+)=(.*)$/,a);t(a);print a[2] > s a[1];}function t(a, i){for(i=1;i<3;i++){gsub(/^\s*|\s*$/,e,a[i]);}}" /etc/sysfs.conf ----------------------------------------------------- ... might be useful to some: ----------------------------------------------------- # cat /etc/sysfs.conf # Set KSM config at boot kernel/mm/ksm/sleep_millisecs = 100 kernel/mm/ksm/run = 1 ----------------------------------------------------- ... btw, as an example of KSMs power: ----------------------------------------------------- # for x in /sys/kernel/mm/ksm/*; do printf "%s\t%s\n" "$(basename "$x")" "$(<"$x")"; done | column -t; echo; free -m full_scans 173 pages_shared 10039 pages_sharing 34206 pages_to_scan 100 pages_unshared 107191 pages_volatile 2578 run 1 sleep_millisecs 100 total used free shared buffers cached Mem: 3958 1072 2886 0 30 293 -/+ buffers/cache: 748 3210 Swap: 2047 0 2047 ----------------------------------------------------- ... this machine runs 4 KVM VMs at 256M each (ie. MORE than 1GB dedicated), and guest + host RAM usage is less than 800MB ... savings will be even more once i convert to 9p2000.L rootfs in all VMs, but that's way OT for this list. also see: http://code.google.com/p/uksm/ -- C Anthony _______________________________________________ uWSGI mailing list uWSGI@lists.unbit.it http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi