Java与Netty实现高性能高并发

netty 高并发快速响应

12-08

现业务是接收http post请求并必须在15毫秒内返回, 我的实现思路: 1:首先netty接收完数据,验证contenttype等header信息再将post的数据protobuf反序列化成对象(必须), 2:然后将对象传入到某个方法, 3:该方法必须定时10毫秒完成,如果没有完成就直接返回null和请求的header 具体实现是: netty 主线程接收完数据转成request对象传到1号线程池里面,1号线程池验证对象和反序列化,传给2号线程池并wait10毫秒然后直接得到2号线程池的返回对象,有就有,没有就是null,然后再channel返回。2号线程池主要处理业务生成对象供1号线程池调用。 Linux version 2.6.32-431.11.25.el6.ucloud.x86_64 gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) Mem: 16G CPU(s): 8 sysctl.conf: net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.netfilter.nf_conntrack_max = 1000000 kernel.unknown_nmi_panic = 0 kernel.sysrq = 1 fs.file-max = 1000000 vm.swappiness = 10 fs.inotify.max_user_watches = 10000000 net.core.wmem_max = 67108864 net.core.rmem_max = 67108864 net.ipv4.conf.all.send_redirects = 0 net.ipv4.conf.default.send_redirects = 0 net.ipv4.conf.all.secure_redirects = 0 net.ipv4.conf.default.secure_redirects = 0 net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.default.accept_redirects = 0 fs.notify.max_queued_events = 3276792 net.ipv4.neigh.default.gc_thresh1 = 2048 net.ipv4.neigh.default.gc_thresh2 = 4096 net.ipv4.neigh.default.gc_thresh3 = 8192 net.ipv6.conf.all.disable_ipv6 = 1 ############## net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_syncookies = 1 net.core.somaxconn = 262144 net.core.netdev_max_backlog = 262144 net.ipv4.tcp_max_orphans = 262144 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 30 #### net.ipv4.tcp_rmem = 4096 87380 67108864 net.ipv4.tcp_wmem = 4096 65536 67108864 net.core.netdev_max_backlog = 250000 net.ipv4.tcp_mtu_probing=1 net.ipv4.tcp_congestion_control=hybla jdk 1.8 现用tomcat同样配置执行是4000qps,超时率为4%; netty是1000qps,超时率为5%; netty: cpu使用10%左右 java -Xms10g -Xmx10g -XX:NewSize=7098m -XX:SurvivorRatio=16 -XX:+DisableExplicitGC -XX:+CMSScavengeBeforeRemark -XX:+UseConcMarkSweepGC -XX:+UParNewGC S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT 403776.0 403776.0 25637.9 0.0 6460800.0 5273672.7 3217408.0 0.0 27928.0 25782.3 3352.0 2883.6 2 0.042 2 1.411 1.453 netstat -apn | grep TIME_WAIT | wl -h 5733 现需要qps达到1w以上。希望收到你的回答或demo。谢谢 ps: akka ,但觉得个人写future和他差不多吧。 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览