C
C
calculator2122021-12-28 16:56:41
go
calculator212, 2021-12-28 16:56:41

How can you measure the performance of an http server?

I read an article there, almost any server can process 3-4 thousand requests per second or more.

I decided to do a little load testing on such a server. But the test results surprised me. Only 10 rps shown. Moreover, the server on asio (c ++) showed the same results. And I've come to the conclusion that I'm most likely testing incorrectly. Therefore, I ask you to help me explain how you can correctly check what load the server can withstand.

Tested like this

siege -t10S -v 127.0.0.1:8080

results
Response time: 2.26 secs
Transaction rate: 10.63 trans/sec
Throughput: 0.06 MB/sec

package main

import (
  "log"
  "net/http"
)

func main() {

  http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    w.WriteHeader(200)
    w.Write([]byte("Hello"))
  })

  log.Fatal(http.ListenAndServe(":8080", nil))

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Mamonov, 2021-12-28
@calculator212

For such a test code, you can use ab (Apache HTTP server benchmarking tool)
For example,
ab -n 10000 -c 1000 http://localhost:8080/
where:
-n is the number of requests to be made
-c is the number of simultaneous requests
Launched on one of the servers, the result is like this

Server Software:
Server Hostname:        localhost
Server Port:            8080

Document Path:          /
Document Length:        5 bytes

Concurrency Level:      1000
Time taken for tests:   0.509 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1210000 bytes
HTML transferred:       50000 bytes
Requests per second:    19627.39 [#/sec] (mean)
Time per request:       50.949 [ms] (mean)
Time per request:       0.051 [ms] (mean, across all concurrent requests)
Transfer rate:          2319.25 [Kbytes/sec] received

Those. with 1000 simultaneous requests, the server will be able to process an average of 19627 requests per second
. But it is important to understand that in a real project you will have more than one endpoint, and that each endpoint, depending on what it will do, will show a different RPS.
For example, if now you add another endpoint and make requests to the database to form a response, the RPS will be much less.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question