Tuesday, October 11, 2022
HomeWordPress DevelopmentGo excessive efficiency http server with Forker

Go excessive efficiency http server with Forker


Get excessive efficiency http requests with fork course of

Go Reference

Get excessive efficiency http requests with fork course of (forker impressed prefork characteristic in net servers)

prefork is an answer which can be utilized by different webservers

A server occasion is opened for every processor core and incoming requests are shared between these cases

So as to distribute the load extra evenly and deal with extra requests per second, there’s a grasp that begins by the consumer, which then begins little one processes on the opposite processor cores based mostly on configuration

reminiscence between the totally different processes is just not shared, beacuse goroutines are unbiased processes

alt text

go get -u github.com/Ja7ad/forker
Enter fullscreen mode

Exit fullscreen mode

forker benchmark

forker examined 500 concurrent with 200k http requests

alt text

oha -c 500 -n 200000 --latency-correction --disable-keepalive http://localhost:8080
Enter fullscreen mode

Exit fullscreen mode

Abstract
  Success price: 1.0000
  Complete:    24.4907 secs
  Slowest:  0.5000 secs
  Quickest:  0.0004 secs
  Common:  0.0610 secs
  Requests/sec: 8166.3762

  Complete information:   2.10 MiB
  Measurement/request: 11 B
  Measurement/sec: 87.72 KiB

Response time histogram:
  0.000

…

Enter fullscreen mode

Exit fullscreen mode

Get excessive efficiency http requests with fork course of (forker impressed prefork characteristic in net servers)

prefork is an answer which can be utilized by different webservers

A server occasion is opened for every processor core and incoming requests are shared between these cases

So as to distribute the load extra evenly and deal with extra requests per second, there’s a grasp that begins by the consumer, which then begins little one processes on the opposite processor cores based mostly on configuration

reminiscence between the totally different processes is just not shared, beacuse goroutines are unbiased processes

Image description

Benchmark With oha 200k request with 500 concurrent

Abstract:
  Success price: 1.0000
  Complete:    24.4907 secs
  Slowest:  0.5000 secs
  Quickest:  0.0004 secs
  Common:  0.0610 secs
  Requests/sec: 8166.3762

  Complete information:   2.10 MiB
  Measurement/request: 11 B
  Measurement/sec: 87.72 KiB

Response time histogram:
  0.000 [1]     |
  0.050 [82408] |â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– 
  0.100 [98705] |â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– â– 
  0.150 [16180] |â– â– â– â– â– 
  0.200 [2245]  |
  0.250 [361]   |
  0.300 [59]    |
  0.350 [33]    |
  0.400 [3]     |
  0.450 [1]     |
  0.500 [4]     |

Latency distribution:
  10% in 0.0291 secs
  25% in 0.0404 secs
  50% in 0.0557 secs
  75% in 0.0754 secs
  90% in 0.0989 secs
  95% in 0.1170 secs
  99% in 0.1581 secs

Particulars (common, quickest, slowest):
  DNS+dialup:   0.0259 secs, 0.0001 secs, 0.3010 secs
  DNS-lookup:   0.0000 secs, 0.0000 secs, 0.0239 secs
Enter fullscreen mode

Exit fullscreen mode

The best way to Set up?

go get -u github.com/Ja7ad/forker
Enter fullscreen mode

Exit fullscreen mode

Instance

bundle foremost

import (
    "github.com/Ja7ad/forker"
    "log"
    "internet/http"
)

func foremost() {
    srv := &http.Server{
        Handler: GreetingHandler(),
    }

    f := forker.New(srv)

    log.Fatalln(f.ListenAndServe(":8080"))

}

func GreetingHandler() http.HandlerFunc {
    return func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("greeting!!!"))
    }
}
Enter fullscreen mode

Exit fullscreen mode

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments