Coder Social home page Coder Social logo

Socket Leak on Linux about nowin HOT 14 CLOSED

bobris avatar bobris commented on August 22, 2024
Socket Leak on Linux

from nowin.

Comments (14)

jchannon avatar jchannon commented on August 22, 2024

Using the new code that you have pushed and using the sample app I linked to and executing this:

!/bin/ash

while true; do
curl http://localhost:1999/ -s
done

The webserver locks up after 5 secs or so.

Any ideas?

from nowin.

jchannon avatar jchannon commented on August 22, 2024

I ran the ab load test tool and here's the results. I told it to do 1000 request with 5 concurrent requests, as you see it only managed 254 requests. Very odd.

screen shot 2015-03-13 at 10 12 42

from nowin.

Bobris avatar Bobris commented on August 22, 2024

Does it at least not leak sockets? Don't have idea, but I am afraid that Saea implementation could have more problems than just does socket leak...
By default I create 256 "connection listeners" so if they will not correctly reset and reuse after disconnect. It could do something like this...

from nowin.

jchannon avatar jchannon commented on August 22, 2024

The socket leak seems to be fixed so thats a good thing.

Interesting that it gives up after 254 requests and you say you have 256 listeners so I suspect something going on there.

from nowin.

Bobris avatar Bobris commented on August 22, 2024

You have -c 5, so +- 5 difference probably don't mean anything.

from nowin.

jchannon avatar jchannon commented on August 22, 2024

ok, i'm a bit in the dark regarding this so if you could point us in the right direction it would be greatly appreciated 😄

from nowin.

jchannon avatar jchannon commented on August 22, 2024

I've submitted a fix to the 256 listeners with #31 however perf is pretty bad

from nowin.

Bobris avatar Bobris commented on August 22, 2024

Already installing Linux to try myself

But you can place this into .config inside element:

  <system.diagnostics>
    <trace autoflush="true" indentsize="0">
    </trace>
    <sources>
      <source name="Nowin.Core">
        <listeners>
          <remove name="Default"/>
          <add name="Nowin.Core" />
        </listeners>
      </source>
      <source name="Nowin.Core.Debug">
        <listeners>
          <remove name="Default"/>
          <add name="Nowin.Core" />
        </listeners>
      </source>
    </sources>
    <switches>
      <add name="Nowin.Core" value="Verbose" />
      <add name="Nowin.Core.Debug" value="Verbose" />
    </switches>
    <sharedListeners>
      <add name="Nowin.Core"
           type="System.Diagnostics.TextWriterTraceListener" 
           initializeData="Nowin.Core.log" />
    </sharedListeners>
  </system.diagnostics>

And send me Nowin.Core.log

Try something minimum what will hang it.
You can reduce number of connections by calling this on ServerBuilder:
.SetConnectionAllocationStrategy(new ConnectionAllocationStrategy(1, 0, 1, 0))

from nowin.

Bobris avatar Bobris commented on August 22, 2024

Aha you found it in mean time. Perfect 👍

from nowin.

jchannon avatar jchannon commented on August 22, 2024

Perf is still bad though so not sure what we can do to improve that. Do you fancy trying it out on your new Linux install? 😄

from nowin.

Bobris avatar Bobris commented on August 22, 2024

Now that you solve it I could return to JS UI Framework I am developing. .Net + Linux is not critical right now for me, I am hoping it will be solved by MS till end of this year anyway :-)
Nowin solved for me problem of needing Admin rights to start HttpListener and much easier deployment.

from nowin.

jchannon avatar jchannon commented on August 22, 2024

OK cool. I've ran some very basic load test tools comparing latest nowin release and owin.httplistener from MS on Linux and nowin's performance is pretty bad in comparison, it fails to even run so I'm not sure what's going on underneath, its as if it can't take many concurrent connections. If I drop it from 100 to 10 it at least runs the tests but the perf is still bad, even comparing 1 connection vs 2 concurrent connections you notice a big difference

Here's the stats:
https://gist.github.com/jchannon/45c0bbb0e10db56c7ea2

The endpoint is a Nancy endpoint setup to just return "Hi"

 public class HomeModule : NancyModule
    {
        public HomeModule()
        {
            Get["/"] = _ => "Hi";
        }
    }

from nowin.

Bobris avatar Bobris commented on August 22, 2024

Mono HttpListener does not use Saea (and they probably know why :-)). Mono Socket implementation does not use epool (at least last time I looked) which is critical for speed of 1k+ connections. I don't have time to implement it by native calls for Linux (eventhough it would be interesting). So really hoping than someone will re-implement that completely from scratch. BTW you cannot use Windows implementation on Linux because OS API is completely different (IOCP vs epool). Also for me even higher priority would to use http://stackoverflow.com/questions/18419117/rio-registered-i-o-sockets-in-net in Windows Nowin, but again in this I hope that "cloud optimized" CoreCLR will eventually use that as Saea backend.
I am sorry, I cannot help you much more right now.

from nowin.

borgdylan avatar borgdylan commented on August 22, 2024

I have a related issue #52

from nowin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.