add delay in hasher and rng

This commit is contained in:
Jerome Petazzoni
2015-06-07 19:53:14 -07:00
parent fae45aae43
commit 89abfeefeb
3 changed files with 15 additions and 1 deletions

View File

@@ -6,6 +6,8 @@ set :bind, '0.0.0.0'
set :port, 80
post '/' do
# Simulate a bit of delay
sleep 0.1
content_type 'text/plain'
"#{Digest::SHA2.new().update(request.body.read)}"
end

View File

@@ -1,6 +1,7 @@
from flask import Flask, Response
import os
import socket
import time
app = Flask(__name__)
@@ -19,6 +20,8 @@ def index():
@app.route("/<int:how_many_bytes>")
def rng(how_many_bytes):
# Simulate a little bit of delay
time.sleep(0.1)
return Response(
os.read(urandom, how_many_bytes),
content_type="application/octet-stream")

View File

@@ -361,7 +361,6 @@ Let's repeat the tests with smaller data.
.exercise[
- Open http://[yourVMaddr]:8000/ (from a browser)
- Click on the (few) available buttons
]
@@ -430,6 +429,16 @@ We have available resources.
- Docker Compose supports scaling
- It doesn't deal with load balancing
- For services that *do not* accept connections, that's OK
- Let's scale `worker` and see what happens!
.exercise[
- Run `docker-compose scale worker=4`
- See the impact on CPU load (with top/htop),
<br/>and on compute speed (with web UI)
]
# Scaling HTTP on a single node