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

multiple simultaneous requests #71

Closed
agalera opened this issue Jun 30, 2016 · 6 comments
Closed

multiple simultaneous requests #71

agalera opened this issue Jun 30, 2016 · 6 comments

Comments

@agalera
Copy link

agalera commented Jun 30, 2016

He was performing a test with meinheld, I was trying to test whether it is possible to address several requests at once. I see that the server listens only 1 to 1.

Is there any way to change this? I would like the requests received have the same context and not try a fork process.

I tried to use gunicorn + meinheld, now if I can handle several at a time, but do not share memory for me is a problem. I tried to put --threads 10, but to indicate that parameter only serves 1 to 1

from bottle import run, get
import time


@get("/test_yield")
def test_yield():
    print("init test_yield")
    for x in range(10):
        time.sleep(1)
        yield(str(x))
    print("end test_yield")

if __name__ == "__main__":
    run(server="meinheld", port="9876", host="0.0.0.0")
init test_yield
end test_yield
"127.0.0.1 - - [30/Jun/2016:11:32:59 +0000] "GET /test_yield HTTP/1.1" 200 10 "-" "Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/3.0.5"
init test_yield
end test_yield
"127.0.0.1 - - [30/Jun/2016:11:33:09 +0000] "GET /test_yield HTTP/1.1" 200 10 "-" "Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/3.0.5"
@methane
Copy link
Collaborator

methane commented Jun 30, 2016

While meinheld supports greenlet, I think prefork is better way for most use cases.
I think gunicorn + meinheld behind nginx is the best practice you should consider first.

but do not share memory for me is a problem.

Why? How many processes do you use? What is your app's bottleneck? (instead of time.sleep()).

@agalera
Copy link
Author

agalera commented Jun 30, 2016

I need to have a list of users connected by websocket to be able to broadcast to everyone. For this I need everyone to have the same context

The server receives POST requests and send this information to all websockets. Therefore it is necessary to share memory, if not, could not send to all users.

@methane
Copy link
Collaborator

methane commented Jun 30, 2016

You shouldn't use meinheld's websocket.
It is very experimental and based on old spec.

@methane
Copy link
Collaborator

methane commented Jun 30, 2016

asyncio or Tornado is what you should use.

@agalera
Copy link
Author

agalera commented Jun 30, 2016

I tried Gevent, is quite similar to meinheld and if I get the part concurrency. I am sorry not to use meinheld :(

@agalera
Copy link
Author

agalera commented Sep 24, 2016

from meinheld import patch
patch.patch_all()

solved :)

@agalera agalera closed this as completed Sep 24, 2016
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