性能包括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. Modular Inverse (拓展欧几里得求逆元)

    The modular modular multiplicative inverse of an integer a modulo m is an integer xsuch that a-1≡x ( ...

  2. window环境下安装Python2和Python3

    一.  python 安装 1. 下载安装包 https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi # 2.7安装包 htt ...

  3. java 并发完成任务之CountDownLatch

    1.CountDownLatch是一个同步辅助类,犹如倒计时计数器,创建对象时通过构造方法设置初始值,调用CountDownLatch对象的await()方法则处于等待状态,调用countDown() ...

  4. Notepad++中F3直接搜索选中文字

    用了Notepad++好久了,一直被"F3不能直接搜索选中文字"困扰.毕竟以前习惯UltraEdit的这种操作,很便捷.今天突然发现原来Notepad++快捷键里可以修改这个功能, ...

  5. Gym - 100989

    B Although Haneen was able to solve the LCS problem, Dr. Ibrahim is suspicious about whether she rea ...

  6. 使用 PuTTY 时遇到错误:“expected key exchange group packet from server”

    情况 使用 PuTTY 通过 SSH 访问 ProxySG 或 Advanced Secure Gateway (ASG) 时,您会看到如下错误:"expected key exchange ...

  7. 《HTTP权威指南》之HTTP连接管理及对TCP性能的考虑

    在上一篇博客中(<HTTP权威指南>之HTTP相关概念详解)我们简单对HTTP相关的基本概念做了一些简单的了解,但未对HTTP连接管理的内容做一些详细的介绍.本篇博客我们就一起来看一下HT ...

  8. Nginx图片服务器

    最近总项目因为需要显示图片,就使用了Nginx,使用很简单,下面简单介绍一下怎么用 压缩包下载地址,解压即用 http://files.cnblogs.com/files/sanduweiliangx ...

  9. RegExp正则表达式内容

    在线测试工具:http://leaverou.github.io/regexplained/ RegExp 对象表示正则表达式,它是对字符串执行模式匹配的强大工具. 直接量语法:/pattern/at ...

  10. 浅谈 .NET Framework 与 .NET Core 的区别与联系

    2017到了,咱们学点啥啊,要想知道学点啥,先弄清.NET Framework 与 .NET Core  这两个概念 .当今 net 生态系统如下: 从上面图中我们可以看到.net  主要分为三个部分 ...