DonHaul opened a new issue #9873:
URL: https://github.com/apache/pulsar/issues/9873


   
   Performance of  Regular org.apache.pulsar.client.api, is about 5x slower 
then admin org.apache.pulsar.client.admin to fetch single messages that were 
already consumend.
   
   I am implementing a reader that needs to fetch 1 document at a time from 
bookeeper in a non sequential way.
   
   Using a regular Reader to fetch a single document it takes around 119ms to 
fetch one message, while using the admin api it takes around 20ms is there any 
reason for this disparity?
   
   I fetched 1000 messages using both methods  to get those average times:
   
   Reader API:
   ```
           PulsarClient client = PulsarClient.builder()
                   .serviceUrl("pulsar://localhost:6650")
                   .build();
   
           Reader reader = client.newReader()
                   
.topic("persistent://apache/pulsar/baby-yoda").startMessageId(MessageId.earliest)
                   .startMessageIdInclusive()
                   .receiverQueueSize(1) //only fetches a single document
                   .create();        
   
           MessageId messageId= //somemessageid
   
           int counter=0;
   
           while (counter<1000) {
   
               reader.seek(messageId);
               Message document = reader.readNext();
   
               counter++;
           }
   ```
   
   Admin API
   ```
   PulsarAdmin admin =  
PulsarAdmin.builder().serviceHttpUrl("http://localhost:8080";).build();
   
           
           Message m = null;
   
           byte[] msg;
   
   while (counter<1000) {
             
           //topic ledger entry
           try {
               msg = 
admin.topics().getMessageById("testtopic3",4,982).getData();
           } catch (PulsarAdminException e) {
               e.printStackTrace();
           }
     counter++;
           }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to