Spring Pulsar Template is slow compared to native pulsar producer #577
Replies: 4 comments 9 replies
-
Hi @chaitanya-guttula-collibra , Thanks for the detailed report. We did a comparison a while back and the performance was equal (and in some cases better when caching the same topic). We plan on putting this into a standard CI workflow so that in case something creeps in we will notice it - we do not have that workflow in place yet though. A couple of possible causes:
Next steps
Sound like a plan? |
Beta Was this translation helpful? Give feedback.
-
Hi @onobc, Thank you for your quick response. Please find the sample used for testing. I also want to correct the scenario 2 that I added above. 100k messages - 6 partitioned topic
|
Beta Was this translation helpful? Give feedback.
-
Hi Edgar,
For some reason your comment is not showing up in the UI thread. I copied
it directly into the discussion below replied - PTAL.
…On Fri, Feb 23, 2024 at 3:37 PM Edgar Molina ***@***.***> wrote:
hi, my team is facing a similar problem, i believe the issue is that when
we use a producerCustomizer at the message level, just as
@chaitanya-guttula-collibra
<https://github.com/chaitanya-guttula-collibra> is doing in his code:
mbs = pulsarTemplate1.newMessage(new ExampleMessage()).withTopic(topicWithSchema).withProducerCustomizer(producer -> {
producer.enableBatching(true);
producer.compressionType(CompressionType.LZ4);
producer.blockIfQueueFull(true);
producer.batchingMaxMessages(1_000);
producer.batchingMaxPublishDelay(100, TimeUnit.MILLISECONDS);
producer.batchingMaxBytes(1024 * 1024);
}).sendAsync();
The sendAsync() will create a new producer per message here
https://github.com/spring-projects/spring-pulsar/blob/main/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarTemplate.java#L236
and here
https://github.com/spring-projects/spring-pulsar/blob/main/spring-pulsar/src/main/java/org/springframework/pulsar/core/PulsarTemplate.java#L289
.
So i guess the question is how can we globally customize the producer
properties of the pulsar template (enable compression, batching, etc.) and
not per message.
—
Reply to this email directly, view it on GitHub
<#577 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AG4RTQZWTHH2DVJSTAPKDV3YVEDZ3AVCNFSM6AAAAABDIP2Z7WVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DKNZTGEZTC>
.
You are receiving this because you were mentioned.Message ID:
<spring-projects/spring-pulsar/repo-discussions/577/comments/8573131@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
The outcome of the discussion was the the PulsarTemplate was performing on par w/ the native Pulsar producer. Closing as resolved. |
Beta Was this translation helpful? Give feedback.
-
What is the best way to use spring pulsar template so that it is efficient in sending messages? Spring Pulsar template is almost 8 times slower than native pulsar producer. We did some performance testing for message production using Gatling with 100K & 1 million messages of 2KB. Please see the results below
1 million messages - 6 partitioned topic
Native pulsar
Pulsar Template
Native Pulsar is 7.4 times faster
### 100k messages - 6 partitioned topic- Native pulsar- Time taken 1 min 1s - 61s- Throughput - 1639 msg/sec- Pulsar Template- Time taken - 8 min 2s - 482- Throughput - 207 msgs/sec- Native pulsar is 7.9 times faster100k messages - non partitioned topic
Native pulsar
Pulsar Template
Native pulsar is 11.9 times faster
Please let me know if you need additional information.
Beta Was this translation helpful? Give feedback.
All reactions