Skip to content

Commit 3fa30b3

Browse files
authored
chore: Update README.md
1 parent 80ed603 commit 3fa30b3

File tree

1 file changed

+98
-97
lines changed

1 file changed

+98
-97
lines changed

README.md

Lines changed: 98 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,99 +2,6 @@
22
[![Docker Stars](https://img.shields.io/docker/stars/sjdonado/bit.svg)](https://hub.docker.com/repository/docker/sjdonado/bit)
33
[![Docker Image Size](https://img.shields.io/docker/image-size/sjdonado/bit/latest)](https://hub.docker.com/repository/docker/sjdonado/bit)
44

5-
# Benchmark
6-
7-
```shell
8-
$ ./benchmark.sh
9-
Setting up...
10-
[+] Running 3/3
11-
✔ Network bit_default Created 0.0s
12-
✔ Volume "bit_sqlite_data" Created 0.0s
13-
✔ Container bit Started 0.1s
14-
Captured API Key: aHOCnZSuo2kOHy2mDa-iOA
15-
Waiting for the application to be ready...
16-
HTTP/1.1 200 OK
17-
Connection: keep-alive
18-
Content-Type: application/json
19-
Date: Sun, 27 Oct 2024 11:52:33 GMT
20-
Access-Control-Allow-Origin: *
21-
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
22-
Access-Control-Allow-Headers: Content-Type, Accept, Origin, X-Api-Key
23-
Content-Length: 13
24-
25-
Starting resource usage monitoring...
26-
Creating 10000 short links with parallel requests...
27-
Link creation complete: 10000 links created.
28-
Fetching all created links from /api/links...
29-
Selected link for benchmarking: http://localhost:4000/oEKLAg
30-
Starting benchmark with Bombardier...
31-
Bombarding http://localhost:4000/oEKLAg with 10000 request(s) using 100 connection(s)
32-
10000 / 10000 [===============================================================================] 100.00% 844/s 11s
33-
Done!
34-
Statistics Avg Stdev Max
35-
Reqs/sec 857.65 1577.98 5255.85
36-
Latency 116.99ms 10.31ms 133.59ms
37-
HTTP codes:
38-
1xx - 0, 2xx - 0, 3xx - 10000, 4xx - 0, 5xx - 0
39-
others - 0
40-
Throughput: 362.05KB/s
41-
Benchmark completed.
42-
Analyzing resource usage...
43-
**** Results ****
44-
Average CPU Usage: 43.20%
45-
Average Memory Usage: 25.52 MiB
46-
```
47-
48-
# Self-hosted
49-
50-
## Run via docker-compose
51-
52-
```bash
53-
docker-compose up
54-
55-
# Generate an api key
56-
docker-compose exec -it app cli --create-user=Admin
57-
```
58-
59-
## Run via docker cli
60-
61-
```bash
62-
docker run \
63-
--name bit \
64-
-p 4000:4000 \
65-
-e ENV="production" \
66-
-e DATABASE_URL="sqlite3://./sqlite/data.db?journal_mode=wal&synchronous=normal&foreign_keys=true" \
67-
-e APP_URL="http://localhost:4000" \
68-
sjdonado/bit
69-
70-
docker exec -it bit cli --create-user=Admin
71-
```
72-
73-
## Dokku
74-
75-
```dockerfile
76-
FROM sjdonado/bit
77-
```
78-
79-
```bash
80-
dokku apps:create bit
81-
82-
dokku domains:set bit bit.donado.co
83-
dokku letsencrypt:enable bit
84-
85-
dokku storage:ensure-directory bit-sqlite
86-
dokku storage:mount bit /var/lib/dokku/data/storage/bit-sqlite:/usr/src/app/sqlite/
87-
88-
dokku config:set bit DATABASE_URL="sqlite3://./sqlite/data.db?journal_mode=wal&synchronous=normal&foreign_keys=true" APP_URL=https://bit.donado.co
89-
90-
dokku ports:add bit http:80:4000
91-
dokku ports:add bit https:443:4000
92-
93-
dokku run bit cli --create-user=Admin
94-
```
95-
96-
# Usage
97-
985
## API Endpoints
996

1007
1. **Ping the API**
@@ -257,10 +164,104 @@ Options:
257164
--delete-user=USER_ID Delete a user by ID
258165
```
259166
260-
# Development
167+
## Benchmark
168+
169+
```
170+
$ ./benchmark.sh
171+
Setting up...
172+
[+] Running 3/3
173+
✔ Network bit_default Created 0.0s
174+
✔ Volume "bit_sqlite_data" Created 0.0s
175+
✔ Container bit Started 0.1s
176+
Captured API Key: aHOCnZSuo2kOHy2mDa-iOA
177+
Waiting for the application to be ready...
178+
HTTP/1.1 200 OK
179+
Connection: keep-alive
180+
Content-Type: application/json
181+
Date: Sun, 27 Oct 2024 11:52:33 GMT
182+
Access-Control-Allow-Origin: *
183+
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
184+
Access-Control-Allow-Headers: Content-Type, Accept, Origin, X-Api-Key
185+
Content-Length: 13
186+
187+
Starting resource usage monitoring...
188+
Creating 10000 short links with 100 conrurrent requests...
189+
Link creation complete: 10000 links created.
190+
Fetching all created links from /api/links...
191+
Selected link for benchmarking: http://localhost:4000/UaVZjA
192+
Starting benchmark with Bombardier...
193+
Bombarding http://localhost:4000/oEKLAg with 10000 request(s) using 100 connection(s)
194+
10000 / 10000 [===============================================================================] 100.00% 830/s 12s
195+
Done!
196+
Statistics Avg Stdev Max
197+
Reqs/sec 853.89 1625.49 8942.54
198+
Latency 118.48ms 11.52ms 142.58ms
199+
HTTP codes:
200+
1xx - 0, 2xx - 0, 3xx - 10000, 4xx - 0, 5xx - 0
201+
others - 0
202+
Throughput: 360.02KB/s
203+
Benchmark completed.
204+
Analyzing resource usage...
205+
**** Results ****
206+
Average CPU Usage: 40.68%
207+
Average Memory Usage: 28.62 MiB
208+
./benchmark.sh: line 135: 61567 Terminated: 15 monitor_resource_usage
209+
[+] Running 2/2
210+
✔ Container bit Removed 10.1s
211+
✔ Network bit_default Removed
212+
```
213+
214+
## Self-hosted
215+
216+
### Run via docker-compose
217+
218+
```bash
219+
docker-compose up
220+
221+
# Generate an api key
222+
docker-compose exec -it app cli --create-user=Admin
223+
```
224+
225+
### Run via docker cli
226+
227+
```bash
228+
docker run \
229+
--name bit \
230+
-p 4000:4000 \
231+
-e ENV="production" \
232+
-e DATABASE_URL="sqlite3://./sqlite/data.db?journal_mode=wal&synchronous=normal&foreign_keys=true" \
233+
-e APP_URL="http://localhost:4000" \
234+
sjdonado/bit
235+
236+
docker exec -it bit cli --create-user=Admin
237+
```
238+
239+
### Dokku
240+
241+
```dockerfile
242+
FROM sjdonado/bit
243+
```
244+
245+
```bash
246+
dokku apps:create bit
247+
248+
dokku domains:set bit bit.donado.co
249+
dokku letsencrypt:enable bit
250+
251+
dokku storage:ensure-directory bit-sqlite
252+
dokku storage:mount bit /var/lib/dokku/data/storage/bit-sqlite:/usr/src/app/sqlite/
253+
254+
dokku config:set bit DATABASE_URL="sqlite3://./sqlite/data.db?journal_mode=wal&synchronous=normal&foreign_keys=true" APP_URL=https://bit.donado.co
255+
256+
dokku ports:add bit http:80:4000
257+
dokku ports:add bit https:443:4000
258+
259+
dokku run bit cli --create-user=Admin
260+
```
261261

262-
## Installation
262+
## Development
263263

264+
- Setup
264265
```bash
265266
brew tap amberframework/micrate
266267
brew install micrate
@@ -270,13 +271,13 @@ brew install micrate
270271
shards run bit
271272
```
272273

273-
## Generate the `X-Api-Key`
274+
- Generate the `X-Api-Key`
274275

275276
```bash
276277
shards run cli -- --create-user=Admin
277278
```
278279

279-
## Run tests
280+
- Run tests
280281

281282
```bash
282283
ENV=test crystal spec

0 commit comments

Comments
 (0)