<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Hi Quan Tong Anh.</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Mon, Nov 25, 2013 at 10:05 PM, Quan Tong Anh <span dir="ltr"><<a href="mailto:anhquankitty@gmail.com" target="_blank">anhquankitty@gmail.com</a>></span> wrote:<br>
</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div> - Python 2.7.3</div>
<div> - [twisted, version 13.1.0]</div><div> - xen-domU</div><div><br></div><div>`atop` shows that `carbon-relay` is eating 80, 90% USRCPU. >From the `strace`:</div><div><br></div><div>
    accept(7, {sa_family=AF_INET, sin_port=htons(60649), sin_addr=inet_addr("192.237.222.81")}, [16]) = 257</div><div>    accept(7, {sa_family=AF_INET, sin_port=htons(51564), sin_addr=inet_addr("166.78.1.48")}, [16]) = 257</div>

<div>    accept(7, 0x7ffff4679550, [16])         = -1 EAGAIN (Resource temporarily unavailable)</div><div>    accept(7, {sa_family=AF_INET, sin_port=htons(33654), sin_addr=inet_addr("198.61.194.248")}, [16]) = 257</div>

<div>    accept(7, {sa_family=AF_INET, sin_port=htons(50037), sin_addr=inet_addr("<a href="tel:166.78.181.204" value="+16678181204" target="_blank">166.78.181.204</a>")}, [16]) = 257</div><div>    accept(7, 0x7ffff4679550, [16])         = -1 EAGAIN (Resource temporarily unavailable)</div>

<div><br></div><div>The strange thing is: even restart the service, it seems stuck at fd 7 everytime running `strace`. Does it mean this fd is not being cleanup properly?</div></div></blockquote><div><br></div><div>You have given a lot of data, but haven't actually described a problem. Nothing is "stuck" at FD 7, it's simply a listening socket file descriptor, and the way listening sockets work is you call accept() repeatedly on them to get incoming connections.</div>
<div><br></div><div>accept() returning EAGAIN is normal behavior and should basically be ignored. Twisted handles this case appropriately. From the man page:</div><div><br></div><div><div>       EAGAIN or EWOULDBLOCK</div>
<div>              The socket is marked nonblocking and no connections are present to be accepted.  POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities.</div>
</div><div><br></div><div>Is there actually something wrong with your service? Can you explain the behavior you're seeing and how it differs from the behavior you want to see? If the problem is only "carbon uses a lot of CPU", maybe the problem is either just that carbon is inefficient or you need to scale up to more instances?</div>
<div><br></div></div><br clear="all"><div><br></div>-- <br>Christopher Armstrong<br><a href="http://radix.twistedmatrix.com/" target="_blank">http://radix.twistedmatrix.com/</a><br><a href="http://planet-if.com/" target="_blank">http://planet-if.com/</a><br>
<br>
</div></div>