0

Should I keep using parallel stream here or should I go with sequential stream. I have tested it on various environments. In my local it was considerably fast but in the test environment, it was slower. doc is a list of strings of size 30K appx. Please suggest.

doc.parallelStream().filter(transaction -> StringUtils.isNotBlank(transaction))
                .forEach(transaction -> sendTransactionsToTopic(transaction, isEncryptionEnabled))
Bhanu Mittal
  • 61
  • 3
  • 11
  • 1
    And what `sendTransactionsToTopic()` does? – Alexander Ivanchenko Sep 16 '22 at 19:10
  • Did you test with ~30K strings on local and test environment both and those ~30K strings somewhat identical on both the environments ? – SRJ Sep 17 '22 at 16:19
  • Refer this https://stackoverflow.com/questions/23170832/java-8s-streams-why-parallel-stream-is-slower you may get idea about how parallel streams works. – Umesh Sulakude Sep 18 '22 at 12:28
  • @AlexanderIvanchenko it sends a string (length=20 apps) to azure service bus topic – Bhanu Mittal Sep 19 '22 at 03:00
  • @shubham yes, both were identical. – Bhanu Mittal Sep 19 '22 at 03:01
  • 1
    @BhanuMittal On your local environment , are you connecting to azure Service bus topic also or you are pointing to any local testable event based system. If no then it could be possible your network calls might be causing this issue for you. – Mukesh Sep 19 '22 at 06:19
  • How is the configuration of test environment compared to local setup like resources(CPU, RAM) ? Is there any resource intensive service running on the same instance of test environment along with your code ? I assume you ran the same parallel stream code on both the machines. – SRJ Sep 19 '22 at 12:07

0 Answers0