Mesure de la performance Redis

Processus d'écriture

--5000 fois à 100 en même temps ... Rapide 11msec

sh-3.2$ ab -n5000 -c100 -r "http://127.0.0.1/set"
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        Apache/2.4.25
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /set
Document Length:        201 bytes

Concurrency Level:      100
Time taken for tests:   0.595 seconds
Complete requests:      5000
Failed requests:        0
Non-2xx responses:      5000
Total transferred:      1895000 bytes
HTML transferred:       1005000 bytes
Requests per second:    8403.46 [#/sec](mean)
Time per request:       11.900 [ms](mean)
Time per request:       0.119 [ms](mean, across all concurrent requests)
Transfer rate:          3110.27 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       3
Processing:     1   11   3.4     11      21
Waiting:        1   11   3.4     11      21
Total:          4   12   3.5     12      21

Percentage of the requests served within a certain time (ms)
  50%     12
  66%     13
  75%     14
  80%     15
  90%     16
  95%     17
  98%     19
  99%     20
 100%     21 (longest request)

--10000 fois à 100 en même temps ... Rapide 15msec

sh-3.2$ ab -n10000 -c100 -r "http://127.0.0.1/set"
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.4.25
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /set
Document Length:        201 bytes

Concurrency Level:      100
Time taken for tests:   1.475 seconds
Complete requests:      10000
Failed requests:        0
Non-2xx responses:      10000
Total transferred:      3790000 bytes
HTML transferred:       2010000 bytes
Requests per second:    6777.55 [#/sec](mean)
Time per request:       14.755 [ms](mean)
Time per request:       0.148 [ms](mean, across all concurrent requests)
Transfer rate:          2508.49 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.6      1      24
Processing:     1   14   5.2     15      47
Waiting:        1   14   5.2     15      47
Total:          4   15   5.4     15      48

Percentage of the requests served within a certain time (ms)
  50%     15
  66%     17
  75%     18
  80%     19
  90%     20
  95%     21
  98%     22
  99%     24
 100%     48 (longest request)

Processus de lecture

――5000 fois à 100 en même temps ... C'est rapide! 11 ms

sh-3.2$ ab -n5000 -c100 -r "http://127.0.0.1/get"
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        Apache/2.4.25
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /get
Document Length:        201 bytes

Concurrency Level:      100
Time taken for tests:   0.556 seconds
Complete requests:      5000
Failed requests:        0
Non-2xx responses:      5000
Total transferred:      1895000 bytes
HTML transferred:       1005000 bytes
Requests per second:    9000.20 [#/sec](mean)
Time per request:       11.111 [ms](mean)
Time per request:       0.111 [ms](mean, across all concurrent requests)
Transfer rate:          3331.13 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.3      1       3
Processing:     1   10   3.5     10      19
Waiting:        1   10   3.4     10      19
Total:          3   11   3.7     11      20

Percentage of the requests served within a certain time (ms)
  50%     11
  66%     13
  75%     14
  80%     14
  90%     16
  95%     17
  98%     18
  99%     19
 100%     20 (longest request)
sh-3.2$ ab -n5000 -c200 "http://127.0.0.1/get"
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
apr_socket_recv: Connection reset by peer (54)

--10000 fois avec 100 en même temps ... Cela fonctionne avec 100 en même temps.

sh-3.2$ ab -n10000 -c100 "http://127.0.0.1/get"
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.4.25
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /get
Document Length:        201 bytes

Concurrency Level:      100
Time taken for tests:   1.339 seconds
Complete requests:      10000
Failed requests:        0
Non-2xx responses:      10000
Total transferred:      3790000 bytes
HTML transferred:       2010000 bytes
Requests per second:    7467.42 [#/sec](mean)
Time per request:       13.392 [ms](mean)
Time per request:       0.134 [ms](mean, across all concurrent requests)
Transfer rate:          2763.82 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.6      1      11
Processing:     1   12   4.3     11      22
Waiting:        1   12   4.3     11      22
Total:          3   13   4.8     12      23

Percentage of the requests served within a certain time (ms)
  50%     12
  66%     15
  75%     17
  80%     19
  90%     20
  95%     22
  98%     22
  99%     22
 100%     23 (longest request)

Référence: Traitement vide

――Mesurez la vitesse lorsque rien n'est fait (la vitesse uniquement pour Flask). ――Il est de 13 ms.

sh-3.2$ ab -n10000 -c100 -r "http://127.0.0.1/"
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.4.25
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /
Document Length:        1799 bytes

Concurrency Level:      100
Time taken for tests:   1.354 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      20460000 bytes
HTML transferred:       17990000 bytes
Requests per second:    7387.12 [#/sec](mean)
Time per request:       13.537 [ms](mean)
Time per request:       0.135 [ms](mean, across all concurrent requests)
Transfer rate:          14759.82 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.8      1      14
Processing:     1   12   3.8     12      30
Waiting:        1   12   3.8     12      30
Total:          3   13   4.2     14      32

Percentage of the requests served within a certain time (ms)
  50%     14
  66%     15
  75%     16
  80%     17
  90%     19
  95%     19
  98%     23
  99%     27
 100%     32 (longest request)

Erreur dans Apache Bench ...

Programme d'essai

――C'est le programme utilisé pour ce test.

app.py


import os
import sys
import redis
import random
from flask import Flask
from datetime import datetime as dt

app = Flask(__name__)

#S'il se trouve dans le chemin de connexion ou dans la variable d'environnement, il a la priorité
REDIS_URL = os.environ.get('REDIS_URL') if os.environ.get(
    'REDIS_URL') != None else 'redis://localhost:6379'
#Spécifier la base de données
DATABASE_INDEX = 1  #Osez 1 au lieu de 0
#Obtenez-en un dans le pool de connexions
pool = redis.ConnectionPool.from_url(REDIS_URL, db=DATABASE_INDEX)
#Utiliser la connexion
r = redis.StrictRedis(connection_pool=pool)

@app.route('/')
def root():
    return '{"status":"OK"}'

@app.route('/get')
def get():
    n = random.randrange(len(r.keys()))
    key = r.keys()[n]
    return str(r.get(key))

@app.route('/set')
def set():
    tdatetime = dt.now()
    key = tdatetime.strftime('%Y-%m-%d %H:%M:%S')
    r.set(key, {'val': key})
    return '{"action":"set"}'

if __name__ == '__main__':
    app.run()

Recommended Posts

Mesure de la performance Redis
Résumé de la mesure des performances NVMe
Mesure de la performance du réseau avec iperf
Outil de mesure des performances des applications Web Funkload ...
Translocation de fichiers CSV en Python Partie 2: Mesure des performances