Coder Social home page Coder Social logo

Comments (5)

mathvav avatar mathvav commented on May 22, 2024

Look at issue #4. He elaborates on his benchmarks and provides some of the background information behind his benchmarks.

from fasthttp.

nanoant avatar nanoant commented on May 22, 2024

@Annonomus-Penguin I have seen that. But my doubt are something else, first is preffered usage SO_REUSEPORT & prefork rather than normal multi-threaded. There's nothing about that in #4. Another is claim that fasthttp works 4x-10x than net/http. Again I cannot see the proof (example benchmark) for this claim.

Just to be clear, I am not denying that this solution is fast, it is VERY FAST. And it is 4th in my benchmarks, only loosing to some heavily optimized Java and 2 native C solution. So I think it is great.

from fasthttp.

valyala avatar valyala commented on May 22, 2024

@nanoant , first of all thanks for the benchmark.

According to your Performance optimization tips for multi-core systems using pre-fork with SO_REUSEPORT is preferred way to scale on multicore system.
However I get completely opposite numbers, when using prefork I get worse results (~440kreq/s) than with multi-threded simpler version (~480kreq).

Prefork with SO_REUSEPORT scales perfectly when a lot of concurrent client connections (at least thouthands) are established over the real network (preferrably 10Gbit with per-CPU hardware packet queues). See #4 for details. When small number of concurrent client connections are established over localhost, then SO_REUSEPORT usually doesn't give any performance gain (like in your case).

Also another important observation is that is performance increase comparing to net/http is around 1.8x, and it is nowhere close to claimed 4x-10x. Thoughts?

10x performance gain is achieved in synthetic benchmarks - see server benchmark results on the main page. These benchmarks completely skip network API provided by the operating system - they test bare server implementation performance. In real life fasthttp is faster than net/http by up to 3x (when client uses http pipelining) due to network API overhead.

As for the source code:

Replace

io.WriteString(ctx, "Hello World")

with

ctx.Write(helloWorldBytes)

where helloWorldBytes must be initialized in global scope as:

var helloWorldBytes = []byte("Hello World")

This may improve benchmark performance, since it eliminates io.WriteString overhead.

from fasthttp.

valyala avatar valyala commented on May 22, 2024

Just added io.WriteString performance booster at 80105c1. @nanoant, make go get -u github.com/valyala/fasthttp and re-run your tests.

from fasthttp.

valyala avatar valyala commented on May 22, 2024

Closing this issue, since this is not a bug.

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.