Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does wait on even work? #117

Open
VasiliPupkin256 opened this issue Sep 14, 2021 · 4 comments
Open

Does wait on even work? #117

VasiliPupkin256 opened this issue Sep 14, 2021 · 4 comments

Comments

@VasiliPupkin256
Copy link

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?

@jiangwenyuan
Copy link
Owner

@VasiliPupkin256 Where do you send the requests? can you enable debug and upload the log?
make sure the docker port mapping is correct

@VasiliPupkin256
Copy link
Author

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()

@jiangwenyuan
Copy link
Owner

@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 -

@VasiliPupkin256
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants