From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id D79C87F6D for ; Fri, 14 Nov 2014 11:43:43 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 14 Nov 2014 02:53:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,385,1413270000"; d="scan'208";a="607772646" Received: from bricha3-mobl3.ger.corp.intel.com ([10.243.20.28]) by orsmga001.jf.intel.com with SMTP; 14 Nov 2014 02:53:26 -0800 Received: by (sSMTP sendmail emulation); Fri, 14 Nov 2014 10:53:25 +0025 Date: Fri, 14 Nov 2014 10:53:25 +0000 From: Bruce Richardson To: Kamraan Nasim Message-ID: <20141114105325.GB13232@bricha3-MOBL3> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org, Yuanzhang Hu Subject: Re: [dpdk-dev] Load-balancing position field in DPDK load_balancer sample app vs. Hash table X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Nov 2014 10:43:44 -0000 On Thu, Nov 13, 2014 at 01:29:32PM -0500, Kamraan Nasim wrote: > Hello, > > So i've borrowed some code from the DPDK Load balancer sample application, > specifically the load balancing position(byte 29th) to determine which > worker lcore to forward the packet to. > > The idea is that flow affinity should be maintained and all packets from > the same flow would have the same checksum/5-tuple value > > worker_id = packet[load_balancing_field] % n_workers > > Question is that how reliable is this load balancing position? I am tempted > to use Hash tables but I think this position based mechanism may be faster. > > How have people's experience with this been in general? > Using a modulus "%" operation will be far, far faster than doing a hash table lookup, though obviously it is not as flexible. [If you have a power-of-two number of workers, you can replace the "%" by "&", if you like to shave off another few cycles]. As for reliability, I'm afraid it depends entirely on your application and what field you pick as to whether it works for load balancing or not. /Bruce