性能包括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的更多相关文章

  1. python协程(yield、asyncio标准库、gevent第三方)、异步的实现

    引言 同步:不同程序单元为了完成某个任务,在执行过程中需靠某种通信方式以协调一致,称这些程序单元是同步执行的. 例如购物系统中更新商品库存,需要用"行锁"作为通信信号,让不同的更新 ...

  2. asyncio标准库2 Hello Clock

    如何调度协程,并发运行 asyncio.gather方法可以聚合协程or future def gather(*coros_or_futures, loop=None, return_exceptio ...

  3. asyncio标准库7 Producer/consumer

    使用asyncio.Queue import asyncio import random async def produce(queue, n): for x in range(1, n + 1): ...

  4. asyncio标准库6 Threads & Subprocess

    Threads import asyncio def compute_pi(digits): # implementation return 3.14 async def main(loop): di ...

  5. asyncio标准库5 TCP echo client and server

    server import asyncio async def handle_echo(reader, writer): data = await reader.read(100) message = ...

  6. asyncio标准库3 HTTP client example

    import aiohttp import asyncio import async_timeout async def fetch(session, url): async with async_t ...

  7. asyncio标准库1 Hello World

    利用asyncio的event loop,编写和调度协程 coroutine [,kəuru:'ti:n] n. 协程 Simple coroutine(调用1个协程) import asyncio ...

  8. 转--Python标准库之一句话概括

    作者原文链接 想掌握Python标准库,读它的官方文档很重要.本文并非此文档的复制版,而是对每一个库的一句话概括以及它的主要函数,由此用什么库心里就会有数了. 文本处理 string: 提供了字符集: ...

  9. Python 标准库一览(Python进阶学习)

    转自:http://blog.csdn.net/jurbo/article/details/52334345 写这个的起因是,还是因为在做Python challenge的时候,有的时候想解决问题,连 ...

随机推荐

  1. new Date("2018-01-01 11:11:11").valueOf() 在IE下会返回 NaN

    原因是在ie下 new Date不能处理 小横线 这种时间格式,但是 替换成 斜线就可以正常获得毫秒数,像下面这样: new Date(('2018-01-01 11:11:11').replace( ...

  2. 112th LeetCode Weekly Contest Minimum Increment to Make Array Unique

    Given an array of integers A, a move consists of choosing any A[i], and incrementing it by 1. Return ...

  3. 《STL详解》读书笔记

    vector 向量容器v.insert(v.begin(), num);//增加v.erase(v.begin(), v.end()); //擦除v.erase(v.begin());reverse( ...

  4. 第五次 Scrum Meeting

    第五次 Scrum Meeting 写在前面 会议时间 会议时长 会议地点 2019/4/9 22:00 30min 大运村1号楼6F 附Github仓库:WEDO 例会照片 工作情况总结(4.9) ...

  5. 2019.03.28 读书笔记 关于lock

    多线程就离不开lock,lock的本质是一个语法糖,采用了监视器Monitor. lock的参数,错误方式有很多种,只需要记住一种:private static readonly object loc ...

  6. DP Intro - Tree POJ2342 Anniversary party

    POJ 2342 Anniversary party (树形dp 入门题) Anniversary party Time Limit: 1000MS   Memory Limit: 65536K To ...

  7. 理解 glibc malloc:主流用户态内存分配器实现原理

    https://blog.csdn.net/maokelong95/article/details/51989081 Understanding glibc malloc 修订日志: 2017-03- ...

  8. 接口隔离原则(Interface Segregation Principle)ISP

    using System; using System.Collections.Generic; using System.Text; namespace InterfaceSegregationPri ...

  9. 60分钟内从零起步驾驭Hive实战学习笔记(Ubuntu里安装mysql)

    本博文的主要内容是: 1. Hive本质解析 2. Hive安装实战 3. 使用Hive操作搜索引擎数据实战 SparkSQL前身是Shark,Shark强烈依赖于Hive.Spark原来没有做SQL ...

  10. 【ExtJS】关于alias和xtype

    alias 在api里的解释为:别名 类名称简短的别名列表.多数用于定义xtypes Ext.define('MyApp.Panel', { extend: 'Ext.panel.Panel', al ...