Skip to content

Commit

Permalink
run counter test with 1000 samples
Browse files Browse the repository at this point in the history
and tune nginx to be able to handle the load
  • Loading branch information
schnipseljagd committed Jun 24, 2016
1 parent ad206d2 commit 811119c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
5 changes: 3 additions & 2 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM nginx

RUN rm /etc/nginx/conf.d/default.conf
ADD default.conf /etc/nginx/conf.d/
RUN rm /etc/nginx/conf.d/default.conf /etc/nginx/nginx.conf
COPY nginx.conf /etc/nginx/
COPY default.conf /etc/nginx/conf.d/
31 changes: 31 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 2048;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}
20 changes: 7 additions & 13 deletions tests/Test/BlackBoxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,12 @@ public function gaugShouldBeOverwritten()
public function countersShouldIncrementAtomically()
{
$start = microtime(true);
$promises = [
$this->client->getAsync('/examples/some_counter.php?c=0'),
$this->client->getAsync('/examples/some_counter.php?c=1'),
$this->client->getAsync('/examples/some_counter.php?c=2'),
$this->client->getAsync('/examples/some_counter.php?c=3'),
$this->client->getAsync('/examples/some_counter.php?c=4'),
$this->client->getAsync('/examples/some_counter.php?c=5'),
$this->client->getAsync('/examples/some_counter.php?c=6'),
$this->client->getAsync('/examples/some_counter.php?c=7'),
$this->client->getAsync('/examples/some_counter.php?c=8'),
$this->client->getAsync('/examples/some_counter.php?c=9'),
];
$promises = [];
$sum = 0;
for ($i = 0; $i < 1000; $i++) {
$promises[] = $this->client->getAsync('/examples/some_counter.php?c=' . $i);
$sum += $i;
}

Promise\settle($promises)->wait();
$end = microtime(true);
Expand All @@ -74,7 +68,7 @@ public function countersShouldIncrementAtomically()
$metricsResult = $this->client->get('/examples/metrics.php');
$body = (string)$metricsResult->getBody();

$this->assertThat($body, $this->stringContains('test_some_counter{type="blue"} 45'));
$this->assertThat($body, $this->stringContains('test_some_counter{type="blue"} ' . $sum));
}

/**
Expand Down

0 comments on commit 811119c

Please sign in to comment.