zubchenok opened a new issue #1616: PulsarAdmin has a significantly slower 
performance for creating subscriptions
URL: https://github.com/apache/incubator-pulsar/issues/1616
 
 
   #### Expected behavior
   
   PulsarAdmin should have faster performance for subscription creation than 
creating and closing a Consumer.
   
   #### Actual behavior
   
   When I create subscription with PulsarAdmin, it is significantly slower than 
if I create a Consumer.
   
   #### Steps to reproduce
   
   Note: At least until 1.22.0 (including) you can run this performance 
comparison test only against single-node cluster due to bug #1615 
   
   Run the following unit test to check the performance:
   ```
       @Test
       public void subscriptionCreatePerformanceComparisonTest() throws 
Exception
       {
           String host = "vv";
           String cluster = "vv";
   
           String webServiceUrl = "http://"; + host + ":8080";
           String brokerServiceUrl = "pulsar://" + host + ":6650";
           String property = "test-prop-performance";
           String adminRole = "test-admins";
           String namespace = "test-namespace-performance";
           int numberOfSubscriptions = 1000;
           String subscription = "test-subscription";
           ClientConfiguration pulsarConfig = new ClientConfiguration();
   
           PulsarAdmin pulsarAdmin = new PulsarAdmin(new URL(webServiceUrl), 
pulsarConfig);
           // create property if not exists
           try
           {
               PropertyAdmin propertyAdmin = new PropertyAdmin();
               
propertyAdmin.setAdminRoles(Collections.singletonList(adminRole));
               propertyAdmin.setAllowedClusters(ImmutableSet.of(cluster));
               pulsarAdmin.properties().createProperty(property, propertyAdmin);
           }
           catch (PulsarAdminException.ConflictException ignored)
           {
           }
   
           String namespaceName = property + "/" + cluster + "/" + namespace;
           // create namespace if not exists
           try
           {
               pulsarAdmin.namespaces().createNamespace(namespaceName);
           }
           catch (PulsarAdminException.ConflictException ignored)
           {
           }
   
           String result1;
           {
               long start = System.currentTimeMillis();
               CompletableFuture
                       .allOf(IntStream
                               .range(0, numberOfSubscriptions)
                               .mapToObj(i -> {
   
                                   String topic = UUID.randomUUID().toString();
                                   String topicName = "persistent://" + 
namespaceName + "/" + topic;
                                   return 
pulsarAdmin.persistentTopics().createSubscriptionAsync(topicName, subscription, 
MessageId.earliest);
                               })
                               .toArray(CompletableFuture[]::new))
                       .join();
               long finish = System.currentTimeMillis();
               result1 = "createSubscriptionAsync time: " + (finish - start) / 
1000d;
               System.out.println(result1);
           }
           pulsarAdmin.close();
   
           PulsarClient pulsarClient = PulsarClient.create(brokerServiceUrl, 
pulsarConfig);
   
           String result2;
           {
               long start = System.currentTimeMillis();
               CompletableFuture
                       .allOf(IntStream
                               .range(0, numberOfSubscriptions)
                               .mapToObj(i -> {
   
                                   String topic = UUID.randomUUID().toString();
                                   String topicName = "persistent://" + 
namespaceName + "/" + topic;
                                   return pulsarClient
                                           .subscribeAsync(topicName, 
subscription)
                                           
.thenComposeAsync(Consumer::closeAsync);
                               })
                               .toArray(CompletableFuture[]::new))
                       .join();
               long finish = System.currentTimeMillis();
               result2 = "subscribeAsync+closeAsync time: " + (finish - start) 
/ 1000d;
           }
           pulsarClient.close();
   
           System.out.println(result1);
           System.out.println(result2);
       }
   ```
   Actual output (FYI my ping to the node in test is ~50ms):
   ```
   [pulsar client logs skipped]
   createSubscriptionAsync time: 20.565
   subscribeAsync+closeAsync time: 7.113
   ```
   
   #### System configuration
   **Pulsar version**: 1.22.0
   Single node/standalone.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to