fastify / fastify/fastify-etag

Fastify etag bringing QPS down for paths where dummy etags have been added

Open
#106 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
85
Forks
17
PR merge metrics
No merged PRs in 30d

Description

### Prerequisites

- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the bug has not already been reported

### Fastify version

4.15.0

### Plugin version

4.2.0

### Node.js version

16.5.1

### Operating system

macOS

### Operating system version (i.e. 20.04, 11.3, 10)

12.6.5

### Description

I used the fastify etag plugin and for the url paths where I did not require etag I added a dummy etag but the QPS for both the paths decreased significantly after adding the plugin

I also tried generating etag myself and this seemed to be give me better QPS. Any reasons for this strange behaviour or is this expected?

```js
const hash = crypto.createHash('sha256');
const stringDoc: string = JSON.stringify(documentData);
etag = hash.update(stringDoc).digest('hex');
```

### Steps to Reproduce

Add `reply.raw.setHeader(etag, 'dummyetag');` to one path's reply and check if there is a drop in QPS

### Expected Behavior

The QPS should not decrease for paths that already have etag headers

Contributor guide

Open the contributing guide

Research direction

Reproduce the QPS comparison with Fastify 4.15.0, the etag plugin 4.2.0, and Node.js 16.5.1, including a path using reply.raw.setHeader(etag, 'dummyetag'). Compare this with the manual crypto.createHash('sha256') approach and determine whether responses that already have etag headers still incur plugin work; done means the expected QPS is preserved for those paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.