Skip to content

Commit eb67b4a

Browse files
committed
docs: add net-loadtest to contributing.md
Also delete previous nixops scripts as they're no longer needed.
1 parent 05610ae commit eb67b4a

File tree

4 files changed

+21
-280
lines changed

4 files changed

+21
-280
lines changed

docs/contributing.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ $ cachix use nxpg
1616
# might take a while in downloading all the dependencies
1717
$ nix-shell
1818

19+
# test on latest pg
20+
$ xpg test
21+
1922
# test on pg 12
2023
$ xpg -v 12 test
2124

2225
# test on pg 13
2326
$ xpg -v 13 test
2427
```
2528

29+
This will spawn a local db and an nginx server for testing.
30+
2631
### Debugging
2732

2833
You can turn on logging level to see curl traces with
@@ -66,32 +71,28 @@ $ sudo net-with-gdb
6671

6772
## Load Testing
6873

69-
These are scripts that wrap NixOps to deploy an AWS cloud setup. You must have `default` setup in `.aws/credentials`.
70-
71-
```bash
72-
net-cloud-deploy
73-
```
74+
The `net-loadtest` launchs a temporary db and a nginx server, waiting until a number of requests are done, then reporting results (plus process monitoring) at the end.
7475

75-
Then you can connect on the client instance and do requests to the server instance through `pg_net`.
76+
It takes a two parameters: the number of requests (GETs) and the `pg_net.batch_size`.
7677

7778
```bash
78-
net-cloud-ssh
79-
80-
psql -U postgres
79+
$ net-loadtest 1000 200
80+
...
8181

82-
select net.http_get('http://server');
83-
# this the default welcome page of nginx on the server instance
84-
# "server" is already included to /etc/hosts, so `curl http://server` will give the same result
82+
## Loadtest results
8583

86-
# do some load testing
87-
select net.http_get('http://server') from generate_series(1,1000);
88-
# run `top` on another shell(another `nixops ssh -d pg_net client`) to check the worker behavior
89-
```
84+
| requests | batch_size | time_taken | request_successes | request_failures | last_failure_error |
85+
|-----------:|-------------:|:----------------|--------------------:|-------------------:|:---------------------|
86+
| 1000 | 200 | 00:00:04.198886 | 1000 | 0 | |
9087

91-
To destroy the cloud setup:
88+
## Loadtest elapsed seconds vs CPU/MEM
9289

93-
```bash
94-
net-cloud-destroy
90+
| Elapsed time | CPU (%) | Real (MB) | Virtual (MB) |
91+
|----------------|-----------|-------------|----------------|
92+
| 0 | 0 | 20.227 | 437.426 |
93+
| 1 | 2 | 20.227 | 437.566 |
94+
| 2.001 | 4 | 20.418 | 437.566 |
95+
| 3.002 | 3 | 20.418 | 437.566 |
9596
```
9697

9798
## Documentation

nix/nixops.nix

Lines changed: 0 additions & 175 deletions
This file was deleted.

nix/nixopsScripts.nix

Lines changed: 0 additions & 79 deletions
This file was deleted.

shell.nix

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ with import (builtins.fetchTarball {
66
mkShell {
77
buildInputs =
88
let
9-
nixpkgs2405 = import (builtins.fetchTarball {
10-
name = "24.05";
11-
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/24.05.tar.gz";
12-
sha256 = "sha256:1lr1h35prqkd1mkmzriwlpvxcb34kmhc9dnr48gkm8hh089hifmx";
13-
}) {};
149
nginxCustom = callPackage ./nix/nginxCustom.nix {};
15-
nixopsScripts = callPackage ./nix/nixopsScripts.nix {nixops_unstable_minimal = nixpkgs2405.nixops_unstable_minimal;};
1610
xpg = callPackage ./nix/xpg.nix {inherit fetchFromGitHub;};
1711
loadtest = callPackage ./nix/loadtest.nix {};
1812
pythonDeps = with python3Packages; [
@@ -27,7 +21,7 @@ mkShell {
2721
nginxCustom.nginxScript
2822
curlWithGnuTls
2923
loadtest
30-
] ++ nixopsScripts;
24+
];
3125
shellHook = ''
3226
export HISTFILE=.history
3327
'';

0 commit comments

Comments
 (0)