redis-benchmark
redis-benchmark是redis自带的一个工具,可用于测试redis的性能
参数说明
1 | Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>] |
redis-benchmark是redis自带的一个工具,可用于测试redis的性能
1 | Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>] |
Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.
You can run atomic operations on these types, like appending to a string; incrementing the value in a hash; pushing an element to a list; computing set intersection, union and difference; or getting the member with highest ranking in a sorted set.
In order to achieve its outstanding performance, Redis works with an in-memory dataset. Depending on your use case, you can persist it either by dumping the dataset to disk every once in a while, or by appending each command to a log. Persistence can be optionally disabled, if you just need a feature-rich, networked, in-memory cache.
Redis also supports trivial-to-setup master-slave asynchronous replication, with very fast non-blocking first synchronization, auto-reconnection with partial resynchronization on net split.
具体可见安装脚本
1 | tar xvzf redis-2.8.24.tar.gz -C /usr/local/ |
生产环境更换nginx之后,sdk发起的请求返回了一个内部定义的401错误,导致用户投诉,跟踪后发现请求中缺失了部分域内容access_token,最终发现nginx会屏蔽掉不合法的请求头,而默认情况下请求头是不支持下划线的。
可以通过使用underscores_in_headers指令开启支持下划线:
Syntax: underscores_in_headers on | off;
Default: underscores_in_headers off;
Context: http, server
同样可以使用ignore_invalid_headers指令把忽略无效的头限制关闭掉,有效的头可以有英文字母,数字,连接符,下划线(受underscores_in_headers指令控制)
Syntax: ignore_invalid_headers on | off;
Default: ignore_invalid_headers on;
Context: http, server
主配置中启动httpd-default.conf
1 | Include conf/extra/httpd-default.conf |
修改httpd-default.conf
1 | ServerTokens Prod |
Loadrunner默认情况下使用ssl2/3,一般情况下后端反向代理会禁用SSLv2和SSLv3,因为SSLv2是不安全的,TLS 1.0在遭受到降级攻击时,会允许攻击者强制连接使用SSLv3,因此Loadrunner采用默认配置发送https的情况下会出现握手失败的情况
可以通过修改所采用的协议来解决
1 | web_set_sockets_option("SSL_VERSION","TLS"); |
HTTP Hypertext Transfer Protocol 超文本传输协议
阅读人群
1 | 客户端->服务器: http请求“请将名为/index.html的文档发给我” |
资源:所有类型的内容来源都是资源
类型:所有HTTP对象数据都会附加一个MIME类型的数据格式标签,用它来描述并标记多媒体内容,浏览器根据MIME类型去知道应该如何处理这个对象。
URI:服务器资源名被称为统一资源标识符(Uniform Resource Identifier URI)
URI有两种形式:URL和URN
ngx_http_limit_req_module用于限制指定key的并发请求数。例如可以限制单个IP地址的请求速率。限制是使用漏桶算法的方法来实现。
例子:
1 | http { |
Syntax: limit_req zone=name [burst=number] [nodelay];
Default: —
Context: http, server, location
当请求速度超过了zone所配置的速度,他们的请求会被延时,就像以所设定的速度在进行请求一样。超出限制的请求数量超过了最大的burst大小,会直接返回503,默认情况下最大的burst为0.
如果不希望超出的请求被延时处理,可以设置nodelay:
1 | limit_req zone=one burst=5 nodelay; |
可以设置多个limit_req指令
1 | limit_req_zone $binary_remote_addr zone=perip:10m rate=1r/s; |
ngx_http_limit_conn_module限制指定key值的并发连接数,如限制单个IP的连接数。
并不是所有连接都会统计,只有当这个请求正在被处理,并且整个请求头已经被读取的情况下,这个连接才会被统计进来。
例子:
1 | http { |