Giter VIP home page Giter VIP logo

Comments (5)

valyala avatar valyala commented on August 29, 2024

fasthttp client reuses keep-alive connections by default.

There is MaxConnsPerHost in the Client and MaxConns in the HostClient for limiting the maximum number of (keep-alive) concurrent connections per host.

fasttp doesn't allow creating more than MaxConnsPerHost connections per host. It returns ErrNoFreeConns if this limit is reached. This effectively limits resource usage on both client and server side unlike net/http, which lacks the ability to limit the maximum number of concurrent connections per host.

from fasthttp.

valyala avatar valyala commented on August 29, 2024

Closing this issue, since this is not a bug :)

from fasthttp.

gobwas avatar gobwas commented on August 29, 2024

Thanks!
Yep, this is not a bug =)

In my case it will be more useful, to set both MaxIdleConnsPerHost and MaxConnsPerHost (or just MaxIdleConnsPerHost), cause its ok to get more connections in moment than idle limit, and then simply drop them after peak. Its too tough to return ErrNoFreeConns to client in high load moments.

Does it makes sense?

from fasthttp.

valyala avatar valyala commented on August 29, 2024

Fasthttp client drops unused connections after 10 seconds. So MaxConnsPerHost may be quite high (1000 or more) for peak load if you are sure both client and server have enough resources to handle this load. Otherwise I'd recommend limiting the number of concurrent goroutines calling fasthttp client methods, so it doesn't exceed MaxConnsPerHost.

from fasthttp.

shalako avatar shalako commented on August 29, 2024

Hello @valyala

In considering fasthttp for use in the router for Cloud Foundry, we are concerned that the lack of control of idle Keepalive connections exposes a vulnerability. With many open keepalive connections, a denial of service attack could be executed far more easily than when most connections are closed after handling the request. Managing total open connections is also important, but it isn't the same thing. We would prefer to limit keepalive connections to something much lower than total connections.

Would you be open to reconsidering support of this feature? We would be willing to offer a PR. We are also exploring workarounds that involve counting the number of connections ourselves and appending Connection close when reaching a configured idle keepalive limit.

Thank you!
CF Routing team

from fasthttp.

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.