Performance problems
See original GitHub issueHi!
I want to get know NATS + asyncio-nats-client RPS (request-response case). The test scenario is simple: server.py
import asyncio
import uvloop
from nats.aio.client import Client
async def main(loop):
client = Client()
await client.connect(io_loop=loop)
print('connected')
async def handler(msg):
await client.publish(msg.reply, b'pong')
await client.subscribe('test', queue='workers', cb=handler)
print('subscribed')
if __name__ == '__main__':
loop = uvloop.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main(loop))
print('start listening')
loop.run_forever()
loop.close()
client.py
import asyncio
import sys
import uvloop
from nats.aio.client import Client
async def main(loop):
futures = [
asyncio.ensure_future(client.timed_request('test', b'ping', 1))
for i in range(int(sys.argv[1]))
]
await asyncio.wait_for(asyncio.gather(*futures), 1.0)
if __name__ == '__main__':
loop = uvloop.new_event_loop()
asyncio.set_event_loop(loop)
client = Client()
loop.run_until_complete(client.connect(io_loop=loop))
print('connected')
loop.run_until_complete(main(loop))
How to run:
$ gnatsd
$ python3.6 server.py
$ python3.6 client.py 1000
I cant’ get more than 1000 requests/responses in 1 second on my MacBook Pro (2.3 GHz Intel Core i5). Maybe I do something wrong or it’s library limitations?
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Dealing with Performance Problems
Types of Performance Problems ; Quantity of work (untimely completion, limited production). Poor prioritizing, timing, scheduling; Lost time ; Quality of work ( ......
Read more >What is a performance problem? - IBM
Generally, a performance problem is the result of some workload not getting the resources it needs to complete in time. Or the resource...
Read more >68 Examples of Performance Problems - Simplicable Guide
Overreaction to Criticism, Passive Aggressive Behavior ; Poor Attention to Detail, Poor Budget Control ; Poor Listening Habits, Poor Work Quality.
Read more >6 Common Employee Performance Problems & How to Solve ...
3. Your employees fail to finish tasks on time. Too Much Work ; 4. Your employees lack commitment. Performance Problems - Demotivation ;...
Read more >7 Causes of Employee Performance Problems and How to ...
7 Causes of Employee Performance Problems and How to Deal With Them · 1. Don't have a reason to care · 2. Don't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks everyone for the feedback in this issue. In the next release v0.7.0 the inbox generation will be around twice as fast (although think implementation at https://github.com/nats-io/asyncio-nats/blob/master/nats/aio/nuid.py could be further optimized).
Results:
About random, better to use
SystemRandom
, but move part of code to the top of module: