vendredi 26 juin 2015

What is the guidance on concurrent calls involving HttpClient instances and its methods?

What is the difference between following "concurrent" call scenarios? Which is the preferred way and why?

Scenario 1:

Thread 1 => Create new HttpClient (C1) and invoke GetAsync to endpoint A

Thread 2 => Create new HttpClient (C2) and invoke GetAsync to endpoint A

Thread 3 => Create new HttpClient (C3) and invoke GetAsync to endpoint A

Scenario 2:

Create one HttpClient (Instance C)

Thread 1: Use C instance and invoke GetAsync to endpoint A

Thread 2: Use C instance and invoke GetAsync to endpoint A

Thread 3: Use C instance and invoke GetAsync to endpoint A

Both scenarios seem to be opening multiple connections to endpoint, except that Scenario 1 has overhead of creating and initializing multiple HttpClient instances at the beginning.




Aucun commentaire:

Enregistrer un commentaire