pawelmhm.github.io's People
pawelmhm.github.io's Issues
ignore
Enforce HTTPS
GitHub now lets you enforce HTTPS for *.github.io
domains:
https://github.com/blog/2186-https-for-github-pages
The site already works over HTTPS without errors: https://pawelmhm.github.io So this should be a trivial fix.
Aiohttp limits the number of simultaneous connections
Thanks for your post on aiohttp - https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html
When I tried to run the client/server code locally to benchmark I noticed the server was receiving connections in batches of 100 approx. This seriously limits the performance.
I found this answer on stackoverflow on why it's happening - https://stackoverflow.com/a/43857526
The script in blog can be modified to following to fix this
# modified fetch function with semaphore
import asyncio
from aiohttp import TCPConnector, ClientSession
async def fetch(url, session):
async with session.get(url) as response:
delay = response.headers.get("DELAY")
date = response.headers.get("DATE")
print("{}:{} with delay {}".format(date, response.url, delay))
return await response.text()
async def bound_fetch(sem, url, session):
# Getter function with semaphore.
async with sem:
await fetch(url, session)
async def run(r):
url = "http://localhost:8000/{}"
tasks = []
# create instance of Semaphore
sem = asyncio.Semaphore(1000)
# Create client session that will ensure we dont open new connection
# per each request.
conn = TCPConnector(limit=0)
async with ClientSession(connector=conn) as session:
for i in range(r):
# pass Semaphore and session to every GET request
task = asyncio.ensure_future(bound_fetch(sem, url.format(i), session))
tasks.append(task)
responses = asyncio.gather(*tasks)
await responses
number = 10000
asyncio.run(run(number))
Consider using go-httpbin instead of httpbin
Hey, dude, thank you for your post about 1m requests.
I really liked it, and it helped me much. But I guess there is a need to add go-httpbin instead of default httpbin. The default one was giving me ServerDisconnected
&& ClientConnector
errors. Also, I think, it's an option to add ulimit -n ${SIZE_OF_SEMAPHORE}
and use aiohttp.TCPConnector(limit=SIZE_OF_SEMAPHORE)
which would definitely increase performance.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.