Skip to content

Commit

Permalink
metrics visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
dsalahutdinov committed Nov 21, 2024
1 parent d019748 commit ff4d9f1
Show file tree
Hide file tree
Showing 11 changed files with 540 additions and 0 deletions.
11 changes: 11 additions & 0 deletions experiments/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

source 'https://rubygems.org/'

ruby '~> 3.3'

gem 'puma', git: 'https://github.com/dsalahutdinov/puma.git', branch: :add_preprocess_time
gem 'rack'
gem 'rackup'
gem 'yabeda-prometheus-mmap'
gem 'yabeda-puma-plugin', path: '/yabeda-puma-plugin'
24 changes: 24 additions & 0 deletions experiments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Navigate to experiments directory:
```sh
cd experiments
```

Setup environment
```sh
docker-compose run app bundle

docker-compose up grafana promethes app
```

To run stress-test:

```sh
docker-compose run k6
```

Navagate to grafana http://localhost:3000 to "Puma experimental" dashboard.

See results:

![Results](docs/puma-requests_wait_time.png)

8 changes: 8 additions & 0 deletions experiments/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'rack'

run do |_env|
# do some hard work
number = (0..9_999_990).to_a.map { |i| i * 2 }.sum

[200, {}, ["Result #{number}"]]
end
84 changes: 84 additions & 0 deletions experiments/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
x-app-resources: &x-app-resources
deploy:
resources:
reservations:
cpus: '1'
memory: 512M
limits:
cpus: '1'
memory: 512M

x-app-service-template: &ruby-app
image: ruby:3.3
environment:
HISTFILE: /app/tmp/.bash_history
BUNDLE_PATH: /usr/local/bundle
BUNDLE_CONFIG: /app/.bundle/config
prometheus_multiproc_dir: /tmp
stdin_open: true
tty: true
working_dir: /app
# tmpfs:
# - /tmp

services:
app:
<<:
- *ruby-app
- *x-app-resources
command: bundle exec puma -t 16 -w 4 -C puma.rb
volumes:
- bundler_data:/usr/local/bundle
- .:/app:cached
- ..:/yabeda-puma-plugin

k6:
image: grafana/k6
command: run /app/k6.js
profiles: [manual-run]
volumes:
- .:/app:cached
sysctls:
- net.ipv4.tcp_tw_reuse=1

prometheus:
image: prom/prometheus:v2.17.1
container_name: prometheus
volumes:
- ./prometheus:/etc/prometheus
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
restart: unless-stopped
expose:
- 9090
depends_on:
- app

grafana:
image: grafana/grafana:11.2.2-security-01
container_name: grafana
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=password
- GF_USERS_ALLOW_SIGN_UP=false
restart: unless-stopped
expose:
- 3000
ports:
- "3000:3000"
depends_on:
- prometheus

volumes:
bundler_data:
prometheus_data:
grafana_data:
12 changes: 12 additions & 0 deletions experiments/grafana/provisioning/dashboards/dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: 1

providers:
- name: 'Prometheus'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
allowUiUpdates: true
options:
path: /etc/grafana/provisioning/dashboards
Loading

0 comments on commit ff4d9f1

Please sign in to comment.