I am trying this on a very vanilla install of Sanic websockets.
from sanic import Sanic
from sanic.websocket import WebSocketProtocol
app = Sanic()
@app.websocket('/feed')
async def feed(request, ws):
while True:
data = 'hello!'
print('Sending: ' + data)
await ws.send(data)
data = await ws.recv()
print('Received: ' + data)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000, protocol=WebSocketProtocol)
Running this on my 4 core i7-7700 CPU @ 3.60GHz
with 48GB
memory.
artillery run sample.yml
# sample.yml
config:
target: "ws://localhost:8000/feed"
phases:
- duration: 20
arrivalRate: 10
ws:
rejectUnauthorized: false
scenarios:
- engine: "ws"
flow:
- send: "hello"
- think: 20
- send: "world"
The results seem okay.
Started phase 0, duration: 20s @ 00:13:24(+0200) 2018-12-31
Report @ 00:13:34(+0200) 2018-12-31
Scenarios launched: 99
Scenarios completed: 0
Requests completed: 99
RPS sent: 10.02
Request latency:
min: 0.1
max: 0.8
median: 0.2
p95: 0.2
p99: 0.5
Codes:
0: 99
Report @ 00:13:44(+0200) 2018-12-31
Scenarios launched: 101
Scenarios completed: 0
Requests completed: 101
RPS sent: 10.1
Request latency:
min: 0.1
max: 1.6
median: 0.1
p95: 0.2
p99: 1.5
Codes:
0: 101
Report @ 00:13:54(+0200) 2018-12-31
Scenarios launched: 0
Scenarios completed: 100
Requests completed: 100
RPS sent: 10.11
Request latency:
min: 0.1
max: 0.3
median: 0.2
p95: 0.3
p99: 0.3
Codes:
0: 100
Report @ 00:14:04(+0200) 2018-12-31
Scenarios launched: 0
Scenarios completed: 100
Requests completed: 100
RPS sent: 10.09
Request latency:
min: 0.1
max: 0.3
median: 0.2
p95: 0.3
p99: 0.3
Codes:
0: 100
All virtual users finished
Summary report @ 00:14:04(+0200) 2018-12-31
Scenarios launched: 200
Scenarios completed: 200
Requests completed: 400
RPS sent: 10.03
Request latency:
min: 0.1
max: 1.6
median: 0.2
p95: 0.3
p99: 0.3
Scenario counts:
0: 200 (100%)
Codes:
0: 400
When I bump up that arrivalRate
to the 2000
that you have in your config, I get:
Warning:
CPU usage of Artillery seems to be very high (pids: 24059)
which may severely affect its performance.
See https://artillery.io/docs/faq/#high-cpu-warnings for details.
Which leads me to my next question, what kind of hardware are you running it on? To create 2000 new connections every second for 20 seconds is a lot of simultaneous connections requiring more resources than my beefy laptop can handle.
It seems like you may be running into hardware issues, and need a strategy to achieve greater horizontal scaling.
Question:
- What hardware are you running?
- What target level of throughput/traffic are you aiming for?