asyncio标准库4 asyncio performance
性能包括2部分
每秒并发请求数(Number of concurrent requests per second)
每秒请求负载(Request latency in seconds: min/average/max time to complete a request)
Architecture: Worker processes
由于python的全局锁(GIL),程序只能运行在单核上,为增加并发处理能力,一个解决方案是分布在多个工作进程
Stream limits
aiohttp使用set_writer_buffer_limits(0)方法以支持反压力(backpressure),实现缓存(buffer)
TCP_NODELAY
3.6版本开始,asyncio在新建socket的同时,可以设置TCP_NODELAY选项,在发送合并(coalescing)的时候禁用Nagle算法
Nagle算法
以他的发明人John Nagle的名字命名的,它用于自动连接许多的小缓冲器消息;这一过程(称为nagling)通过减少必须发送包的个数来增加网络软件系统的效率
TCP_QUICKACK
TCP_QUICKACK(TCP延迟确认机制),用于让本端立即发送ACK,而不进行延迟确认。asyncio默认不使用这个选项
Tune the Linux kernel
/proc/sys/net/ipv4/tcp_mem
/proc/sys/net/core/rmem_default and /proc/sys/net/core/rmem_max:
The default and maximum amount for the receive socket memory
/proc/sys/net/core/wmem_default and /proc/sys/net/core/wmem_max:
The default and maximum amount for the send socket memory
/proc/sys/net/core/optmem_max:
The maximum amount of option memory buffers
net.ipv4.tcp_no_metrics_save
net.core.netdev_max_backlog:
Set maximum number of packets, queued on the INPUT side, when the interface receives packets faster than kernel can process them.
asyncio标准库4 asyncio performance的更多相关文章
- python协程(yield、asyncio标准库、gevent第三方)、异步的实现
引言 同步:不同程序单元为了完成某个任务,在执行过程中需靠某种通信方式以协调一致,称这些程序单元是同步执行的. 例如购物系统中更新商品库存,需要用"行锁"作为通信信号,让不同的更新 ...
- asyncio标准库2 Hello Clock
如何调度协程,并发运行 asyncio.gather方法可以聚合协程or future def gather(*coros_or_futures, loop=None, return_exceptio ...
- asyncio标准库7 Producer/consumer
使用asyncio.Queue import asyncio import random async def produce(queue, n): for x in range(1, n + 1): ...
- asyncio标准库6 Threads & Subprocess
Threads import asyncio def compute_pi(digits): # implementation return 3.14 async def main(loop): di ...
- asyncio标准库5 TCP echo client and server
server import asyncio async def handle_echo(reader, writer): data = await reader.read(100) message = ...
- asyncio标准库3 HTTP client example
import aiohttp import asyncio import async_timeout async def fetch(session, url): async with async_t ...
- asyncio标准库1 Hello World
利用asyncio的event loop,编写和调度协程 coroutine [,kəuru:'ti:n] n. 协程 Simple coroutine(调用1个协程) import asyncio ...
- 转--Python标准库之一句话概括
作者原文链接 想掌握Python标准库,读它的官方文档很重要.本文并非此文档的复制版,而是对每一个库的一句话概括以及它的主要函数,由此用什么库心里就会有数了. 文本处理 string: 提供了字符集: ...
- Python 标准库一览(Python进阶学习)
转自:http://blog.csdn.net/jurbo/article/details/52334345 写这个的起因是,还是因为在做Python challenge的时候,有的时候想解决问题,连 ...
随机推荐
- LightOJ - 1234 分块预处理
求∑1/i,但是范围很大 和bitmap的想法一样,分个块,均摊复杂度就降下来了 //到底排行榜上的0ms是怎么做到的? #include<bits/stdc++.h> using nam ...
- [转] JQuery UI Tabs 动态添加页签,并跳转到新页签
[From] https://blog.csdn.net/zhangfeng2124/article/details/76672403 需求: 1.tabs默认只有一个页签,但是需要点击某按钮,动态添 ...
- [转] 理解SVG transform坐标变换
http://www.zhangxinxu.com/wordpress/2015/10/understand-svg-transform/
- 【记录】drozer与adb工具的安装与使用
drozer:链接:https://pan.baidu.com/s/1o8QOIF4 密码:a7yv adb:链接:https://pan.baidu.com/s/1o865VSm 密码:zq9t d ...
- git 代码统计
查看git上的个人代码提交量: git log --author="Marek Romanowski" --since="2019-01-01" --no-me ...
- PIE SDK栅格拉伸控制
1. 功能简介 在我们的实际应用中,对于一般16bit或者更大比特深度的影像,像元值都是大于255的.这种情况下,RGB的显示器是不能够直接使用像元值进行显示的,需要将像元值换算到0~255的区间内以 ...
- UltraEdit 21.3 增加 mssql, json 高亮
1. %appdata%\IDMComp\UltraEdit 2. 将msql2k.uew, json.uew 放到 wordfiles 目录即可 msql2k json的uew 下载地址如 ...
- oracle执行update语句卡住不动
一.问题探究 开发的时候debug到一条update的sql语句时程序就不动了,然后我就在plsql上试了一下,发现plsql一直在显示正在执行,等了好久也不出结果.但是奇怪的是执行其他的select ...
- NFS 优化及详解
一, 启动过程: 所以启动的时候一定一定要先启用——————rpcbind———————————————— 启动 rpcbind ------>/etc/init.d/rpcbind rest ...
- Ansible 命令相关模块command, shell, raw, expect, script, telnet[转]
本文主要介绍Ansible的几个命令模块,包括: command - 在远程节点上执行命令 shell - 让远程主机在shell进程下执行命令 script - 将本地script传送到远程主机之后 ...