Graylog2 / Graylog2/graylog2-server
Codec is initialised on each incoming message
- Dominant language
- Java
- Stars
- 8.1k
- Forks
- 1.1k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 217
Description
## Expected Behavior
Codec should be initialised once when MessageInput is initialised (e.g. ```gelfCodecFactory.create(configuration)``` in [GELFHttpInput:42](https://github.com/Graylog2/graylog2-server/blob/master/graylog2-server/src/main/java/org/graylog2/inputs/gelf/http/GELFHttpInput.java#L42)
Instead, it is initialised on each message in [DecodingProcessor:142](https://github.com/Graylog2/graylog2-server/blob/master/graylog2-server/src/main/java/org/graylog2/shared/buffers/processors/DecodingProcessor.java#L142):
```
final Codec codec = factory.create(raw.getCodecConfig());
```
## Possible Solution
The problem is that codec can contain some heavy initialisation (e.g. read some format details from configuration files), which causes overall graylog degradation when it is under heavy traffic. So the instance, created during initialisation, should be used.
Maybe one of the solutions is to select, how do you want to use codec:
- per message
- singleton
- pool of instances
If the case when codec should know some configuration details (which are stored in message, as i can see), then details should be passed in `decode()` method.
## Your Environment
graylog in docker
* Graylog Version: 4.3.5
* Java Version: 1.8
Contributor guide
Assessment
This issue has not been assessed yet.