Tuesday 12 November 2013

How do you increase FreeBSD processor performance by 10%?


Turn on powersaving! This may seem counter-intuitive. Old school admins typically turn off all power management in BIOS, and ensure their servers don't go into power saving modes for performance reasons. Today, this isn't necessarily true.

Why?

Intel Turbo Boost. This tech ramps up the single core clock speed in a multicore processor when it's able to (eg when other cores are idle) providing better performance. For this to work, it must be enabled in BIOS as well as OS. In Freebsd, that's handled by powerd (man powerd).

The best  practice now is to enable hiadaptive mode on powerd, which enables TurboBoost, with a secondary benefit of power saving. Some DCs are already billing customers based on power consumption (AIMS!), so this is good to have. That's like having your cake and eating it too.


 hiadaptive  Like adaptive mode, but tuned for systems where performance
   and interactivity are more important than power consumption.
   It increases frequency faster, reduces frequency less aggres-
   sively, and will maintain full frequency for longer.  May be
   abbreviated as hadp.
 
 

Edit your /etc/rc.conf,

powerd_enable="YES"
powerd_flags="-a hiadaptive"


Then

/etc/rc.d/powerd start

You're all set.
 

Switch-independent NIC teaming on FreeBSD



On FreeBSD, teaming/link aggregation is handled by the lagg kernel module (man lagg). What the man pages don't tell you (nor any other site I've googled) is, what exactly is switch-dependent and which isn't. This blog post does.

Failover - switch independent
FEC - switch dependent
LACP - switch dependent (you need switch trunking enabled if you're doing LACP with 2 different physical switches, but this does have the benefit of increasing server bandwidth available for multiple clients)
Loadbalance - switch dependent (same as FEC)
Roundrobin - you will not likely ever use this.


Ok, so I had a case today where I needed to connect a freebsd box to 2 switches for switch high availability support, so there was only 1 option - failover.

HOWTO
=====

1) ifconfig em0 up
2) ifconfig em1 up
3) ifconfig lagg0 create
4) ifconfig lagg0 up laggproto failover laggport em0 laggport em1 <ipaddress> netmask 255.255.255.0
5) route add default <gateway>
6) $$$


In other words, both link 'share' a single IP. To be clear, It is not actually sharing per se, since only the first interface becomes the master port (em0 in the above example), and em1 will not be used unless and until em0 goes physically down. You can do an ifconfig lagg0 to see which port is active.






     failover     Sends traffic only through the active port.  If the master
                  port becomes unavailable, the next active port is used.  The
                  first interface added is the master port; any interfaces
                  added after that are used as failover devices.

                  By default, received traffic is only accepted when they are
                  received through the active port.  This constraint can be
                  relaxed by setting the net.link.lagg.failover_rx_all
                  sysctl(8) variable to a nonzero value, which is useful for
                  certain bridged network setups.

     fec          Supports Cisco EtherChannel.  This is an alias for
                  loadbalance mode.

     lacp         Supports the IEEE 802.3ad Link Aggregation Control Protocol
                  (LACP) and the Marker Protocol.  LACP will negotiate a set
                  of aggregable links with the peer in to one or more Link
                  Aggregated Groups.  Each LAG is composed of ports of the
                  same speed, set to full-duplex operation.  The traffic will
                  be balanced across the ports in the LAG with the greatest
                  total speed, in most cases there will only be one LAG which
                  contains all ports.  In the event of changes in physical
                  connectivity, Link Aggregation will quickly converge to a
                  new configuration.

     loadbalance  Balances outgoing traffic across the active ports based on
                  hashed protocol header information and accepts incoming
                  traffic from any active port.  This is a static setup and
                  does not negotiate aggregation with the peer or exchange
                  frames to monitor the link.  The hash includes the Ethernet
                  source and destination address, and, if available, the VLAN
                  tag, and the IP source and destination address.

     roundrobin   Distributes outgoing traffic using a round-robin scheduler
                  through all active ports and accepts incoming traffic from
                  any active port.