From owner-freebsd-net@FreeBSD.ORG Mon Jul 15 19:53:56 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E8FA6DBC for ; Mon, 15 Jul 2013 19:53:56 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wi0-x22a.google.com (mail-wi0-x22a.google.com [IPv6:2a00:1450:400c:c05::22a]) by mx1.freebsd.org (Postfix) with ESMTP id 8507477E for ; Mon, 15 Jul 2013 19:53:56 +0000 (UTC) Received: by mail-wi0-f170.google.com with SMTP id ey16so3344720wid.1 for ; Mon, 15 Jul 2013 12:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=FFi8r4QIspy4JkFfQ0Yn4KG7s4gPU0ncj+DsuZMfyy4=; b=PLP2/LBkF5wV43xsCbRK6Rju/uCGqScliNIyo9N4aJU2Zqsn+3UvZvUQzbjUNsGZwW VM/fKrDdf7ipoD9ronSXa41jld1uDXwYsRlvVjlaTeUrPNZ4JAUfa1ynS4iwoupW2zG+ Xs/D/nHUCZaZxee+WvSKeLKO9jBcTPGNdZOn1udt3Dn+7suISIVDZipF+sRJq7NUbC82 NzXObr+tncg9p36103PTofn6nhIU8wvkhx6K17Wpu9ZBJauFEOwxek5if8AvrRwdvFYy PTe+naoUK7ZWC6dxDD4/txxumQs0XrK5vVIY4gsQPVVcfHH/ptMQXPbctWrK5DdCgYPs 9/eQ== MIME-Version: 1.0 X-Received: by 10.194.63.229 with SMTP id j5mr32047253wjs.79.1373918035486; Mon, 15 Jul 2013 12:53:55 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.217.94.132 with HTTP; Mon, 15 Jul 2013 12:53:55 -0700 (PDT) In-Reply-To: <51E44E2F.8060700@mail.ru> References: <51E0E2AF.7090404@mail.ru> <51E44E2F.8060700@mail.ru> Date: Mon, 15 Jul 2013 12:53:55 -0700 X-Google-Sender-Auth: QwNw1wSwdin8TxjNz94yd2yTF4E Message-ID: Subject: Re: SO_REUSEPORT: strange kernel balancer behaviour From: Adrian Chadd To: trafdev Content-Type: text/plain; charset=ISO-8859-1 Cc: Sepherosa Ziehau , freebsd-net@freebsd.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jul 2013 19:53:57 -0000 i've noticed this when doing this stuff in a threaded program with each thread listening on the same port. All threads wake up on each accepted connection, one thread wins and the other threads get EAGAIN. -adrian On 15 July 2013 12:31, trafdev wrote: > Thanks for reply. > > This approach produces lot of "resource temporary unavailable" (eagain) on > accept-ing connections in N-1 processes. > Is this possible to avoid this by e.g. tweaking kqueue? > > > On Sun Jul 14 19:37:59 2013, Sepherosa Ziehau wrote: >> >> On Sat, Jul 13, 2013 at 1:16 PM, trafdev wrote: >>> >>> Hello. >>> >>> Could someone help with following problem of SO_REUSEPORT. >> >> >> The most portable "load balance" between processes listening on the >> same TCP addr/port probably is: >> >> s=socket(); >> bind(s); >> listen(s); >> /* various socketopt and fcntl as you needed */ >> pid=fork(); >> if (pid==0) { >> server_loop(s); >> exit(1); >> } >> server_loop(s); >> exit(1); >> >> Even in Linux or DragonFly SO_REUSEPORT "load balance" between >> processes listening on the same TCP addr/port was introduced recently, >> so you probably won't want to rely on it. >> >> Best Regards, >> sephe >> > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"