SMF and TCP Tuning
I recently tuned a few TCP parameters on a Solaris 10 fileserver of mine and I wanted to persist these changes across reboots. Well, you’re not really supposed to stick this stuff in /etc/system anymore, and so the alternative is to set it on boot. This being the age of SMF, I looked for an existing implementation and found this blog post by Hung-Sheng Tsao at Sun. His version was pretty simple, since it’s just a basic manifest that defines running a script in which the calls to ndd and the parameters are hardcoded. I thought it’d be nice if you could define your parameters right in SMF (that’s the point, right? ;) so the result is a new SMF method named nddtune. My version reads the tunables directly from the SMF properties, and also stores the previous values so that disabling the service reverts to the old values. Here’s how you use it:
- Copy the nddtune script to somewhere appropriate for your environment and make sure it is executable. By default, the SMF config expects to find it in /lib/svc/method.
- Copy network-nddtune.xml to /var/svc/manifest/site. Edit the XML config file if you put nddtune somewhere other than /lib/svc/method.
- Import the manifest:
# svccfg import /var/svc/manifest/site/network-nddtune.xml
- Create property groups for the devices you wish to tune. The property group is translated to the device passed to ndd by prepending a slash and converting underscores to slashes, so in this example dev_tcp will result in ‘ndd -set /dev/tcp …’:
# svccfg -s nddtune addpg dev_tcp application
- Set some parameters:
# svccfg -s nddtune setprop dev_tcp/tcp_xmit_hiwat = integer: 4000000 # svccfg -s nddtune setprop dev_tcp/tcp_recv_hiwat = integer: 4000000 # svccfg -s nddtune setprop dev_tcp/tcp_max_buf = integer: 4000000 # svccfg -s nddtune setprop dev_tcp/tcp_cwnd_max = integer: 4000000 - Create an SMF snapshot that includes your new values:
# svcadm refresh nddtune
- Check your current values before enabling:
% ndd -get /dev/tcp tcp_xmit_hiwat 49152 % ndd -get /dev/tcp tcp_recv_hiwat 49152 % ndd -get /dev/tcp tcp_max_buf 1048576 % ndd -get /dev/tcp tcp_cwnd_max 1048576 - Enable the service:
# svcadm enable nddtune
- Check the new values to make sure it worked:
% ndd -get /dev/tcp tcp_xmit_hiwat 4000000 % ndd -get /dev/tcp tcp_recv_hiwat 4000000 % ndd -get /dev/tcp tcp_max_buf 4000000 % ndd -get /dev/tcp tcp_cwnd_max 4000000 - You can disable the service to reset the tunables to their previous values, since the previous values are stored whenever the service is enabled. These previous values are stored in an SMF property group named like the one(s) you created, but with ‘_defaults’ appended:
% /usr/bin/svcprop -p dev_tcp_defaults nddtune dev_tcp_defaults/tcp_xmit_hiwat integer 49152 dev_tcp_defaults/tcp_recv_hiwat integer 49152 dev_tcp_defaults/tcp_max_buf integer 1048576 dev_tcp_defaults/tcp_cwnd_max integer 1048576
You can get nddtune from its repository on bitbucket.
Filed under: everything | Leave a Comment
Tags: ndd, opensolaris, oracle, orasun, smf, solaris, sun, sunracle
No Responses Yet to “SMF and TCP Tuning”