nuster
nuster copied to clipboard
Does `wait on` even work?
I am using the simplest config
global
nuster manager on
nuster cache on data-size 200m
frontend fe
bind *:80
mode http
default_backend be
backend be
mode http
nuster cache on
nuster rule r1 wait on ttl 10m
server s1 127.0.0.1:8080
and running it with a command docker run --rm -it -v $(pwd)/nuster.cfg:/etc/nuster/nuster.cfg:ro --network=host nuster/nuster
When I open a browser and press F5 multiple time it passes multiple requests to the backend. Did I miss something?
@VasiliPupkin256 Where do you send the requests? can you enable debug and upload the log? make sure the docker port mapping is correct
I am sending requests to the app listening on the port 8080. How can I enable the debug log?
This is all you need to reproduce the issue actually. A file nuster.cfg
in the current folder, and a single docker command I used. The only variable here is the backend, but nuster is sending multiple requests to this port before it even gets the first byte of response, so it can be anything even an nc
command probably. Here is one I can use to reproduce the issue:
#!/usr/bin/env python3
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
class handler(BaseHTTPRequestHandler):
def do_GET(self):
print(self.requestline)
while True: pass
ThreadingHTTPServer(('', 8080), handler).serve_forever()
@VasiliPupkin256
docker run --rm -it -v $(pwd)/nuster.cfg:/etc/nuster/nuster.cfg:ro --network=host nuster/nuster nuster -d -f /etc/nuster/nuster.cfg -W
ab -n 100 -c 10 http://127.0.0.1/
only one log:
127.0.0.1 - - [18/Sep/2021 03:19:50] "GET / HTTP/1.0" 200 -
Ok. I see the problem. Nuster terminates the backend request immediately after a client closes connection to the frontend. It doesn't not wait and doesn't fetch the page from the backend completely.
A worse example if there are N identical connections they all wait only for the first one and when the first connection is closed nuster passes another N-1 requests to the backend.
This is not what a caching proxy suppose to do and it is possible to intentionally or unintentionally overload a backend by creating multiple requests to the same URL and terminating them shortly afterwards before the backend were able to respond.