# imgproxy vs alternatives benchmark

## Setup

- c5.xlarge AWS instance: 4 CPUs, 8 GB RAM
- Ubuntu 18.04
- Go 1.12
- Python 2.7
- Vips 8.7.4

All the tools were launched with their default settings except the following (where applicable):

- Concurrency was set to 8;
- Filesystem image source was configured. Where not applicable, local nginx was used as the image source.

## Benchmarking

We used [Apache HTTP server benchmarking tool](https://httpd.apache.org/docs/2.4/programs/ab.html) (a.k.a `ab`):

```
ab -n 1000 -c 4 $url
```

The source image is a [photo of Wat Arun](https://upload.wikimedia.org/wikipedia/commons/b/b7/The_sculptures_of_two_mythical_giant_demons%2C_Thotsakan_and_Sahatsadecha%2C_guarding_the_eastern_gate_of_the_main_chapel_of_Wat_Arun%2C_Bangkok.jpg) (JPEG, 7360x4912, 29MB).

The tools were requested to resize it to fit 500x500.

## Tested tools

- [imgproxy](https://github.com/imgproxy/imgproxy) itself, master branch

   URL: `/unsigned/rs:fit:500:0/plain/local:///wat-arun.jpg`

- [thumbor](https://github.com/thumbor/thumbor), v6.7.0

   URL: `/unsafe/500x0/wat-arun.jpg`

- [imaginary](https://github.com/h2non/imaginary), master branch

   URL: `/fit?width=500&height=500&file=wat-arun.jpg`

- [pilbox](https://github.com/agschwender/pilbox), v1.3.4

   URL: `/?url=http%3A%2F%2Fimages.dev.com%2Fwat-arun.jpg&w=500&h=500&mode=clip`

- [picfit](https://github.com/thoas/picfit), master branch

   URL: `/display/resize/500x0/wat-arun.jpg`

- [imageproxy](https://github.com/willnorris/imageproxy), master branch

   URL: `/500x/http://images.dev.com/wat-arun.jpg`

## Results

| Tool          | Time taken for tests<br>(sec) | Requests per second | Time per request<br>(sec, mean) | Memory peak usage<br>(MB) | Result file size<br>(KB) |
| :------------ | -------------------------: | ------------------: | ---------------------------: | ---------------------: | --------------------: |
| imgproxy      | 103.405                    | 9.67                | 413.618                      | 194                    | 43.51                 |
| thumbor       | 160.505                    | 6.23                | 642.021                      | 461                    | 45.10                 |
| imaginary     | 104.873                    | 9.54                | 419.494                      | 562                    | 92.93                 |
| pilbox        | 179.482                    | 5.57                | 717.927                      | 1060                   | 95.64                 |
| picfit        | 1220.412                   | 0.82                | 4881.646                     | 1934                   | 98.67                 |
| imageproxy    | 1209.361                   | 0.83                | 4837.443                     | 2392                   | 98.74                 |