-
Notifications
You must be signed in to change notification settings - Fork 3k
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
The pycurl client #393
Comments
I don't have an answer to your question, but I'm very confused why you would replace requests with pycurl. Can you elaborate on what you are trying to achieve with this code? |
requests lib is a sync net io lib, so do you have a plan to change it to async lib, maybe python3.5's asyncio. |
And httptools is a nice http response parser, it might speed up the io throughout. |
@likezjuisee: Locust uses gevent which monkey patches python sockets and makes them use asynchronous IO (while maintaining a synchronous programming model). Python-requests gives you an extremely nice API and handles a lot of edge-cases automatically. Therefore it comes with some overhead. Therefore, if your planning to run huge load tests you might benefit from using an HTTP client with less overhead. In that case I would recommend using geventhttpclient (https://github.com/gwik/geventhttpclient). I don't know about PyCurl but I suspect that it's synchronous by default, and since it's written in C, it bypasses gevents monkey patching of socket which will make it run synchronously, which would explain why you would get the same result as running a single user (or worse). Also, I wouldn't expect |
I known the monkey patches, but I guess it may be worse than asyncio. You might look around the web server framework sanic https://github.com/channelcat/sanic, it benefits from the httptools and uvloop. So I supposed you to update the locust to python3.5. If you persist with your own plan, it is ok. ^_^ |
I came upon this issue and know its closed. However, I just wanted to point out one thing. The reason I was looking to use pycurl is to get internal metrics on the actual HTTP call. The "response time" for an call will include multiple things - DNS lookup, TLS negotiation, server latency to process the call, etc. Curl makes those available. That's the reason I was looking to use pycurl. Are those metrics provided via locust today? I didn't see them but thought I'd ask. For reference here's what curl provides for metrics - https://ec.haxx.se/usingcurl-writeout.html |
I want to use pycurl to do the http request, so I make a pycurl client likes below:
coding=utf-8
from locust import Locust, events
import time
import pycurl
from cStringIO import StringIO
from exceptions import AttributeError
class PycurlClient(object):
class PycurlLocust(Locust):
And, I use this client in my new task like this:
coding=utf-8
import pycurl
from locust.pycurlclients import PycurlClient, PycurlLocust
from locust import TaskSet, task
from cStringIO import StringIO
class TestTaskSet(TaskSet):
@task
def index(self):
print '%s get index' % str(self.locust)
self.client.openCurl()
self.client.setopt(pycurl.URL, r'http://www.so.com')
sio = StringIO()
self.client.setopt(pycurl.WRITEFUNCTION, sio.write)
self.client.perform()
self.client.closeCurl()
class TestPycurlClient(PycurlLocust):
max_wait = min_wait = 1
task_set = TestTaskSet
host = r'http://www.so.com'
When the user was 1, the pycurl's performance was better than requests, but when I increased the user's number, the requests number of per second equals to the 1 user almostly. So do you have some suggestions about this?
The text was updated successfully, but these errors were encountered: