zoukankan      html  css  js  c++  java
  • 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.
    
  • 相关阅读:
    原型模式 prototype
    OOAD之单例模式Singleton的6种写法
    OOAD之创建型模式之工厂模式
    OOAD之面向对象设计原则
    第一章 面向对象软件工程与UML
    Oracle数据库之PL/SQL触发器
    Oracle数据库之开发PL/SQL子程序和包
    Oracle数据库中的分页--rownum
    Oracle数据库之FORALL与BULK COLLECT语句
    Oracle数据库 中的基础的一些语法结构
  • 原文地址:https://www.cnblogs.com/liujitao79/p/8601183.html
Copyright © 2011-2022 走看看