superdanby / tcp_server Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v2.0
License: GNU General Public License v2.0
server.py
now yields weird benchmark results. The server clean up time takes as long as the process time.
~> python3 client.py 127.0.0.1 8888 1000000
eof sent
finish writing
wait for server to clean up
1000000 requests done.
Process time: 33.637513160705566s, requests per second: 29728.71374951026, server clean up time: 32.18577456474304s, total time elapsed: 65.82328772544861s
The part in async def respond()
causing this problem:
if Error:
status_code = status_code.decode('utf-8').split(' ', 2)[1]
else:
status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
# status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
# status_code = status_code.decode('utf-8')
# status_code = "212".split('1')[0]
Changing those to the following yields similar results:
# if Error:
# status_code = status_code.decode('utf-8').split(' ', 2)[1]
# else:
# status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
# status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
status_code = status_code.decode('utf-8')
# status_code = "212".split('1')[0]
But if the part doesn't use str.decode():
# if Error:
# status_code = status_code.decode('utf-8').split(' ', 2)[1]
# else:
# status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
# status_code, Error = status_code.decode('utf-8').split(' ', 1)[1].split(' ', 1)
# status_code = status_code.decode('utf-8')
status_code = "212".split('1')[0]
The results are:
~> python3 client.py 127.0.0.1 8888 1000000
eof sent
finish writing
wait for server to clean up
1000000 requests done.
Process time: 66.861887216568s, requests per second: 14956.203625556738, server clean up time: 0.0014019012451171875s, total time elapsed: 66.86328911781311s
Though total time elapsed don't differ a lot, we can cut out the connection from the client once all requests are received(the time it takes would be 'process time'). Hence, it would be a huge impact on the performance.
This makes the server stuck in a state that it only outputs an empty string and not accepting new messages.
The 'Task was destroyed but it is pending!' is sometimes being output when a connection is closed by a client. While this doesn't have a great impact on the server's performance, it is worth investigating.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.