Skip to content

Reuse serializers #1201

Open
Open
@fbad

Description

Hi!

I have profiled Kafka Rest v7.5.0 under some test load (2rps on Produce V2 endpoint with Avro format and schemas registered in Schema Registry, using schema id) and it looks like most of the time inside RecordSerializerFacade.serialize is actually spent reinstantiating the three serializers (Avro, JsonSchema, Protobuf) (you can see how small is the portion spent actually serializing in this profiling).

image

It seems this is due to io/confluent/kafka/serializers/AbstractKafkaSchemaSerDe.addRuleObjectsFromServiceLoader.

  1. Am I interpreting this right? Are serializers reinstantiated for each request?
  2. Would it be possible to reuse the same serializers for different requests? Are they thread-safe? If yes, can we maybe bind SchemaRecordSerializerFactory with singleton scope?

Thank you!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions