ps -ef | grep httpd | wc -lnetstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import math,random | |
| import numpy as np | |
| def rand(a, b): | |
| return (b-a)*random.random() + a | |
| def dtanh(y): | |
| return 1.0-y*y | |
| def mat(x): |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
| <?php | |
| /* | |
| tcp dns client for google dns over https (https://dns.google.com) | |
| ubuntu上使用: | |
| 在/etc/rc.local里加/usr/bin/php /home/<your_name>/dns2https.php | |
| 执行: | |
| sysv-rc-conf unbound off | |
| sysv-rc-conf dnscrypt-proxy off |
| # Configuration file for runtime kernel parameters. | |
| # See sysctl.conf(5) for more information. | |
| # See also http://www.nateware.com/linux-network-tuning-for-2013.html for | |
| # an explanation about some of these parameters, and instructions for | |
| # a few other tweaks outside this file. | |
| # Protection from SYN flood attack. | |
| net.ipv4.tcp_syncookies = 1 |
| ===========================================httperf=========================== | |
| apache bench常碰到"apr_poll: The timeout specified has expired (70007) ", | |
| 测试行业里常用httperf+autobench(有bench2graph生成性能图表): | |
| (共10000连接,每秒10000个连接,每连接1个请求(就没必要分bursts来发了,即connection-oriented或request-oriented workload下--burst-length是在connection之内pipeline)): | |
| httperf --hog --num-conns 10000 --rate 10000 --num-calls=1 --timeout 20 --server 127.0.0.1 --port 8888 --uri / | |
| 等同(共1次会话,每秒1次会话,每次会话10000请求,分若干bursts,每bursts含10000个请求,每bursts间隔1秒,每连接最多1请求,最大连接数10000, | |
| max-connections大于4需要修改httperf/src/gen/session.c为#define MAX_CONN 65536,即session-oriented workload下--burst-length肯能是一个connection内pipeline也可能跨connection): | |
| httperf --hog --wsess=1,10000,1 --rate 1 --burst-length=10000 --max-piped-calls 1 --max-connections=10000 --timeout 20 --server 127.0.0.1 --port 8888 --uri / | |
| #发出超过3000个并行连接PC还是会报"*** buffer overflow detected ***: httperf terminated",不知怎么解决 | |
| #"--hog" means to use all available ports to create connection |
| # xcode-build-bump.sh | |
| # @desc Auto-increment the build number every time the project is run. | |
| # @usage | |
| # 1. Select: your Target in Xcode | |
| # 2. Select: Build Phases Tab | |
| # 3. Select: Add Build Phase -> Add Run Script | |
| # 4. Paste code below in to new "Run Script" section | |
| # 5. Drag the "Run Script" below "Link Binaries With Libraries" | |
| # 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0) |
| 一.积累大量TIME_WAIT连接无法接受新请求: | |
| 比较安全的设置是/etc/sysctl.conf: | |
| net.ipv4.tcp_timestamps=1 | |
| net.ipv4.tcp_tw_recycle=0 | |
| net.ipv4.tcp_tw_reuse=1 | |
| sysctl net.ipv4.tcp_max_tw_buckets=10000 | |
| 参考: http://nick.txtcc.com/index.php/linux/1162 | |
| 二.启动iptables一两个小时后出现大量丢包: | |
| /var/log/messages出现大量nf_conntrack: table full, dropping packet. |