<!-- 
RSS generated by JIRA (1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d) at Thu Feb 08 23:20:37 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>FOLIO Jira</title>
    <link>https://folio-org.atlassian.net</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>1001.0.0-SNAPSHOT</version>
        <build-number>100246</build-number>
        <build-date>07-02-2024</build-date>
    </build-info>

<item>
            <title>[FOLIO-2435] Spike: Running vert.x HttpClient requests in parallel</title>
                <link>https://folio-org.atlassian.net/browse/FOLIO-2435</link>
                <project id="10290" key="FOLIO">FOLIO</project>
                    <description>&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=63e2a2771b13d42998e4e706&quot; class=&quot;user-hover&quot; rel=&quot;63e2a2771b13d42998e4e706&quot; data-account-id=&quot;63e2a2771b13d42998e4e706&quot; accountid=&quot;63e2a2771b13d42998e4e706&quot; rel=&quot;noreferrer&quot;&gt;Marc Johnson&lt;/a&gt; wrote in CIRC-468:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;I think we need to be careful about doing HTTP requests in parallel. I don&apos;t know how the vert.x HttpClient handles this. There is likely a need to improve the logging to help correlate requests and responses.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;High priority because many FOLIO modules already use parallel processing with CompositeFuture:&lt;br/&gt;
&lt;a href=&quot;https://github.com/search?q=org%3Afolio-org+compositefuture&amp;amp;type=Code&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/search?q=org%3Afolio-org+compositefuture&amp;amp;type=Code&lt;/a&gt;&lt;br/&gt;
HttpClient documentation: &lt;a href=&quot;https://vertx.io/docs/apidocs/io/vertx/core/http/HttpClient.html&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vertx.io/docs/apidocs/io/vertx/core/http/HttpClient.html&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="81529">FOLIO-2435</key>
            <summary>Spike: Running vert.x HttpClient requests in parallel</summary>
                <type id="10003" iconUrl="https://folio-org.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10318?size=medium">Task</type>
                                            <priority id="10001" iconUrl="https://dev.folio.org/assets/jira-priority/jira-p2.svg">P2</priority>
                        <status id="6" iconUrl="https://folio-org.atlassian.net/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10003">Done</resolution>
                                                        <assignee accountid="62e181430b4bf7ad924b3732">Steve Ellis</assignee>
                                                                <reporter accountid="5ee89462f7aa140abd82d11d">Julian Ladisch</reporter>
                                    <labels>
                            <label>platform-backlog</label>
                    </labels>
                <created>Tue, 28 Jan 2020 10:00:20 +0000</created>
                <updated>Thu, 24 Feb 2022 19:35:29 +0000</updated>
                            <resolved>Thu, 24 Feb 2022 19:35:29 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>2</watches>
                                                                <comments>
                                                            <comment id="194598" author="63e2a2771b13d42998e4e706" created="Tue, 28 Jan 2020 11:43:15 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=5ee89462f7aa140abd82d11d&quot; class=&quot;user-hover&quot; rel=&quot;5ee89462f7aa140abd82d11d&quot; data-account-id=&quot;5ee89462f7aa140abd82d11d&quot; accountid=&quot;5ee89462f7aa140abd82d11d&quot; rel=&quot;noreferrer&quot;&gt;Julian Ladisch&lt;/a&gt; Thank you for raising this issue.&lt;/p&gt;

&lt;p&gt;Please can you expand upon what your expectations for the output of the spike are?&lt;/p&gt;</comment>
                                                            <comment id="194601" author="5ee89462f7aa140abd82d11d" created="Tue, 28 Jan 2020 12:24:04 +0000"  >&lt;p&gt;Is vert.x HttpClient designed to properly handle parallel HTTP requests? If yes, we can close this issue without any further action. If there are restrictions they should be documented. If HttpClient is not designed to handle parallel HTTP requests we need to change all existing code where HttpClient (or WebClient based on HttpClient) is used in parallel.&lt;br/&gt;
See also &quot;Calling the Service More Than Once&quot; in &quot;Clement Escoffier: Building Reactive Microservices in Java&quot; &lt;a href=&quot;https://www.oreilly.com/programming/free/files/building-reactive-microservices-in-java.pdf#page=35&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.oreilly.com/programming/free/files/building-reactive-microservices-in-java.pdf#page=35&lt;/a&gt;&lt;/p&gt;</comment>
                                                            <comment id="194605" author="63e2a2771b13d42998e4e706" created="Tue, 28 Jan 2020 12:37:17 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=5ee89462f7aa140abd82d11d&quot; class=&quot;user-hover&quot; rel=&quot;5ee89462f7aa140abd82d11d&quot; data-account-id=&quot;5ee89462f7aa140abd82d11d&quot; accountid=&quot;5ee89462f7aa140abd82d11d&quot; rel=&quot;noreferrer&quot;&gt;Julian Ladisch&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok, thank you for that context.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Is vert.x HttpClient designed to properly handle parallel HTTP requests?&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;&lt;a href=&quot;https://vertx.io/docs/vertx-web-client/java/&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vertx.io/docs/vertx-web-client/java/&lt;/a&gt; suggests that the library is asynchronous. Is that sufficient for the definition of parallel here or not?&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;See also &quot;Calling the Service More Than Once&quot; in &quot;Clement Escoffier: Building Reactive Microservices in Java&quot;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;That example uses Vert.x&apos;s RxJava extensions, are you suggesting that FOLIO needs to do the same?&lt;/p&gt;</comment>
                                                            <comment id="194607" author="5ee89462f7aa140abd82d11d" created="Tue, 28 Jan 2020 12:46:17 +0000"  >&lt;p&gt;HttpClient is asynchronous allowing some other task to execute when waiting for the response.&lt;br/&gt;
This does not answer the question whether one HttpClient instance is designed to handle two parallel HTTP requests, or if we need two HttpClient instances.&lt;br/&gt;
RxJava is a wrapper (syntactic sugar) that is automatically generated from the base vert.x code: &lt;a href=&quot;https://vertx.io/docs/vertx-rx/java/#_rxified_api&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vertx.io/docs/vertx-rx/java/#_rxified_api&lt;/a&gt;&lt;br/&gt;
That example from Clement Escoffier shows one HttpClient running two HTTP requests in parallel; I don&apos;t know whether this is an error or intended.&lt;/p&gt;</comment>
                                                            <comment id="194610" author="63e2a2771b13d42998e4e706" created="Tue, 28 Jan 2020 13:06:05 +0000"  >&lt;p&gt;&lt;a href=&quot;https://folio-org.atlassian.net/secure/ViewProfile.jspa?accountId=5ee89462f7aa140abd82d11d&quot; class=&quot;user-hover&quot; rel=&quot;5ee89462f7aa140abd82d11d&quot; data-account-id=&quot;5ee89462f7aa140abd82d11d&quot; accountid=&quot;5ee89462f7aa140abd82d11d&quot; rel=&quot;noreferrer&quot;&gt;Julian Ladisch&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;This does not answer the question whether one HttpClient instance is designed to handle two parallel HTTP requests, or if we need two HttpClient instances.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Ok, so by parallel, that means asynchronous and multiple requests in progress at the same time?&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://vertx.io/docs/vertx-web-client/java/#_creating_a_web_client&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation&lt;/a&gt; suggests that we should not use more than one instance of &lt;tt&gt;HttpClient&lt;/tt&gt; or &lt;tt&gt;WebClient&lt;/tt&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In most cases, a Web Client should be created once on application startup and then reused. Otherwise you lose a lot of benefits such as connection pooling and may leak resources if instances are not closed properly.&lt;/p&gt;&lt;/blockquote&gt;</comment>
                                                            <comment id="194614" author="5ee89462f7aa140abd82d11d" created="Tue, 28 Jan 2020 13:10:37 +0000"  >&lt;blockquote&gt;&lt;p&gt;by parallel, that means asynchronous and multiple requests in progress at the same time?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Yes.&lt;/p&gt;</comment>
                                                            <comment id="194618" author="62e181430b4bf7ad924b3732" created="Thu, 24 Feb 2022 19:35:29 +0000"  >&lt;p&gt;This came up in our backlog as being open and I said something like &quot;It&apos;s vertx so it&apos;s async&quot; and suggested closing it. I think there are two questions in the conversation here: 1) is HttpClient &quot;properly&quot; async, 2) are we instantiating HttpClient in the right way?&lt;/p&gt;

&lt;p&gt;I think the answer to 1 has to be yes considering how widely used the library is and that it is following the normal vertx pattern of either using callbacks or futures to handle IO. For example it does send and then gets an AsyncResult in a callback.&lt;/p&gt;

&lt;p&gt;I think the answer to 2 is it depends on our code. As Marc mentions in the comments the docs for this library suggest one instance per vertx process. In other words it should be static or used as a singleton. Don&apos;t new up an HttpClient instance for every request.&lt;/p&gt;

&lt;p&gt;Adam noticed this just yesterday in the tests for mod-inventory. Too many sockets = too many instances of HttpClient.&lt;/p&gt;

&lt;p&gt;Async IO is at its core about defining a way to wait for a result without blocking the thread. This is why in things like vertx and node the result arrives in a callback. There was also a question in the comments about parallelism. The amount of parallelism (the number of concurrent requests) is dependent on how many simultaneous threads a given processor can handle. So 8 cores will give you more parallelism than 6 etc. The beauty of vertx and all modern approaches to async is that the developer doesn&apos;t have to worry much about this in most cases. You just follow the pattern that the library or language defines (callbacks, async/await, coroutines, whatever) and you&apos;re getting the benefits of multicore processors.&lt;/p&gt;

&lt;p&gt;Some references:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;About vertx being async in general: &lt;a href=&quot;https://vertx.io/docs/vertx-core/java/#_dont_block_me&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://vertx.io/docs/vertx-core/java/#_dont_block_me&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;My send example from above: &lt;a href=&quot;https://github.com/vert-x3/vertx-examples/blob/5ea49a6bb904323009210b67fe0ef42d07e393b9/web-client-examples/src/main/java/io/vertx/example/webclient/response/jsonobject/Client.java#L27&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/vert-x3/vertx-examples/blob/5ea49a6bb904323009210b67fe0ef42d07e393b9/web-client-examples/src/main/java/io/vertx/example/webclient/response/jsonobject/Client.java#L27&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Adam&apos;s issue for mod-inventory: &lt;a href=&quot;https://folio-org.atlassian.net/browse/MODINV-650&quot; class=&quot;external-link&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://folio-org.atlassian.net/browse/MODINV-650&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10000">
                    <name>Blocks</name>
                                            <outwardlinks description="blocks">
                                        <issuelink>
            <issuekey id="46948">CIRC-468</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10000" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummarycf">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10057" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Development Team</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10144"><![CDATA[Core: Platform]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10019" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|hzx3o9:zzr</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10020" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="468">CP: sprint 134</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10044" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.5</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10024" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>[CHART] Date of First Response</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 28 Jan 2020 11:43:15 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10025" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>[CHART] Time in Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>