Challenge - 5 Problems
Split Clients Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of split_clients with 50/50 split
Given the following nginx configuration snippet using
split_clients, what is the value of the variable $variant for the client with IP 192.168.1.10?Nginx
split_clients "$remote_addr" $variant { 50% "A"; * "B"; } # Assume $remote_addr is 192.168.1.10
Attempts:
2 left
💡 Hint
The
split_clients directive hashes the input and assigns variants based on percentage ranges.✗ Incorrect
The
split_clients directive hashes the client IP and assigns the variant based on the defined percentages. Since 50% is assigned to "A" and the rest to "B", the client IP 192.168.1.10 falls into the first 50% bucket, so $variant is "A".❓ Configuration
intermediate1:30remaining
Correct split_clients syntax for 30/70 split
Which of the following nginx
split_clients configurations correctly splits traffic into 30% variant "X" and 70% variant "Y"?Attempts:
2 left
💡 Hint
Percentages must add up to 100%, and the wildcard * covers the rest.
✗ Incorrect
Option A correctly assigns 30% to "X" and the rest (70%) to "Y" using the wildcard *. Option A is invalid because percentages must be in descending order and the wildcard * must be last. Option A is correct syntax-wise but does not use wildcard; however, it is valid if percentages add to 100%. Option A has an extra wildcard causing invalid configuration.
❓ Troubleshoot
advanced2:00remaining
Why does split_clients always assign the same variant?
An nginx config uses
split_clients "$http_user_agent" $variant but all users get assigned variant "A" even though the split is 50/50. What is the most likely cause?Nginx
split_clients "$http_user_agent" $variant { 50% "A"; * "B"; }
Attempts:
2 left
💡 Hint
Check what value is being hashed by split_clients.
✗ Incorrect
If the variable used in split_clients is empty or the same for all users, the hash will always produce the same result, assigning the same variant. $http_user_agent can be identical or missing in some requests, causing this behavior.
🔀 Workflow
advanced2:30remaining
Order of directives for A/B testing with split_clients
What is the correct order of nginx directives to implement A/B testing using
split_clients and setting a cookie for persistent variant assignment?Attempts:
2 left
💡 Hint
You must extract the cookie first, then split, then set cookie if missing.
✗ Incorrect
First, use
map to extract the variant from the cookie. Then use split_clients to assign a variant if cookie is empty. Then set the cookie if it was missing. Finally, the server block contains these directives.✅ Best Practice
expert3:00remaining
Best practice for consistent A/B testing with split_clients
Which approach ensures consistent user experience in nginx A/B testing using
split_clients across multiple sessions?Attempts:
2 left
💡 Hint
Persistence across sessions requires storing variant in a cookie.
✗ Incorrect
Using
split_clients on a cookie value and setting the cookie if missing ensures the user gets the same variant on subsequent visits, providing a consistent experience. Using IP or user agent alone can cause inconsistent assignment.