A simple Rails application to demonstrate the Split gem for A/B testing.
This application provides a single demo page that showcases three A/B test experiments:
- Background Color: white, lightblue, or lightgreen
- Heading Font: serif, sans-serif, or monospace
- Layout Style: centered, left, or right alignment
- Simple, single-view demo application
- 3 visual A/B test experiments that are immediately visible
- Split Dashboard integration for viewing experiment results
- Goal tracking when users click the demo button
- Docker & Docker Compose (recommended)
- Or: Ruby 3.3+, Rails 8.1+, Redis
graph LR
Browser[Browser] -->|http://localhost:8080| Nginx[nginx<br/>Load Balancer]
Nginx -->|Round-robin| App1[app1<br/>Puma :3000]
Nginx -->|Round-robin| App2[app2<br/>Puma :3000]
Nginx -->|Round-robin| App3[app3<br/>Puma :3000]
App1 -->|Session Data| Redis[(Redis)]
App2 -->|Session Data| Redis
App3 -->|Session Data| Redis
This setup simulates a production-like environment with multiple independent Puma instances behind an nginx load balancer.
- Start the application:
docker-compose up --build- Visit the application:
- Demo page: http://localhost:8080
- Split Dashboard: http://localhost:8080/split
- Username:
admin - Password:
secret
- Username:
- View logs from all instances:
docker-compose logs -f app1 app2 app3You'll see requests being distributed across three Puma instances (app1, app2, app3), which helps reproduce issues with Split's multi-server deployment.
- Stop the application:
docker-compose down- Install dependencies:
bundle install- Start Redis:
redis-server- Start the Rails server:
bin/rails server- Visit the application:
- Demo page: http://localhost:3000
- Split Dashboard: http://localhost:3000/split
- Username:
admin - Password:
secret
- Username:
- Alternatives: white, lightblue, lightgreen
- Goal: button_clicked
- Alternatives: serif, sans-serif, monospace
- Goal: button_clicked
- Alternatives: centered, left, right
- Goal: button_clicked
- Open the demo page in different browsers or incognito windows to see different variations
- Click the "Click Me to Track Goal!" button to track the goal
- Visit the Split Dashboard to see experiment results and statistics
- Clear your browser cookies or use incognito mode
- Refresh the page multiple times to see different variations
- Click the goal button to record conversions
- Check the Split Dashboard to see results
To verify that requests are being distributed across multiple Puma instances:
# Send multiple requests and observe the distribution
for i in {1..20}; do
curl -s http://localhost:8080 >/dev/null
sleep 0.1
done
# Watch the logs to see different instances handling requests
docker-compose logs -f app1 app2 app3You should see requests being handled by different instances (app1, app2, app3) in the logs.