HttpSplitClientsModule
(Difference between revisions)
Willybarro (Talk | contribs) m (Murmurhash to Murmurhash2) |
Willybarro (Talk | contribs) (Explaining how the murmurhash2 integer is used to determine which variable value shall be set.) |
||
| Line 20: | Line 20: | ||
</geshi> | </geshi> | ||
| − | On the | + | On the sample configuration above, the input for calculating the percentage is the variable plus string ('''"${remote_addr}AAA"'''). The value of this string is hashed using MurmurHash2 (which will generate a 32bit integer). |
| + | In the example given: | ||
| + | * Hash values from 0 to 1739461754 (40.5%) will set the $variant variable with the value ".one"; | ||
| + | * Hash values from 1739461755 to 4294967295 (59.5%) will set the $variant variable with the value ".two"; | ||
| − | Instead of '''${remote_addr}''', one could use '''${cookie}''', '''${args}''' or | + | == Appendix == |
| + | |||
| + | Instead of '''${remote_addr}''', one could use '''${cookie}''', '''${args}''' or any other [http://wiki.nginx.org/HttpCoreModule#Variables, nginx variable]. You may also add a salt (arbitrary string) if you wish. | ||
* Keep in mind that if you use a variable like '''${remote_addr}''' (user IP), the hash (and percentage) will always be the same as long as the user/client keep the same IP. In other words, the '''$variant''' value will always be the same for the same IP. | * Keep in mind that if you use a variable like '''${remote_addr}''' (user IP), the hash (and percentage) will always be the same as long as the user/client keep the same IP. In other words, the '''$variant''' value will always be the same for the same IP. | ||
Revision as of 14:03, 11 December 2012
Contents |
Synopsis
ngx_http_split_clients_module is used to split clients based on some conditions(e.g ip addresses, headers, cookies, etc).
Examples
Basic configuration:
On the sample configuration above, the input for calculating the percentage is the variable plus string ("${remote_addr}AAA"). The value of this string is hashed using MurmurHash2 (which will generate a 32bit integer). In the example given:
- Hash values from 0 to 1739461754 (40.5%) will set the $variant variable with the value ".one";
- Hash values from 1739461755 to 4294967295 (59.5%) will set the $variant variable with the value ".two";
Appendix
Instead of ${remote_addr}, one could use ${cookie}, ${args} or any other nginx variable. You may also add a salt (arbitrary string) if you wish.
- Keep in mind that if you use a variable like ${remote_addr} (user IP), the hash (and percentage) will always be the same as long as the user/client keep the same IP. In other words, the $variant value will always be the same for the same IP.
- Hashing algorithm is MurmurHash2 since version 1.0.1; Previously CRC32.
Sending a query string variable to 51% of clients (to PHP scripts)
Directives
split_clients
| Syntax: | split_clients string $variable { ... } |
| Default: | |
| Context: | http |
| Reference: | split_clients |










