mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 17:49:59 +00:00
add delay in hasher and rng
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user