Recent

Author Topic: FPHTTPClient speed  (Read 349 times)

lainz

  • Hero Member
  • *****
  • Posts: 3766
  • Leandro Diaz
FPHTTPClient speed
« on: September 19, 2020, 01:55:50 pm »
Hi, say I connect to an endpoint REST with FPHTTPClient.

I can connect a lot of times. To speed up I can use threads to download in parallel or upload in parallel. When a thread finishes I reuse it, I don't free it, so there is some small improvement regarding to thread creation..

What is faster / safer:

- Is better to create a single instance of FPHTTPClient for each thread, and reuse that for each upload / download? Is safe to do this?

- Or create an instance of FPHTTPClient for each upload / download?
« Last Edit: September 19, 2020, 02:07:11 pm by lainz »

lainz

  • Hero Member
  • *****
  • Posts: 3766
  • Leandro Diaz
Re: FPHTTPClient speed
« Reply #1 on: September 19, 2020, 04:40:21 pm »
I will guess the answer...

It will be faster for sure, instead of initializing over and over again the client, it will gain at least some seconds in the long run...

The thing is how to know if is properly clean, say I do a get, then do a get again with the same client, I must be sure that the result is always set, I mean if it's correctly designed will be like that always, and the previous state will be erased and replaced with the new state.

And when doing a Post, is my responsability to ensure that the data I send is the correct one, and the previous data is clean.

So much trouble maybe for a small gain of time.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8274
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: FPHTTPClient speed
« Reply #2 on: September 20, 2020, 11:29:37 am »
A single FPHTTPClient instance behaves like a browser. Whatever cookies sent in previous response, will be kept accordingly for the next request. How the server behaves, is dependant on that server implementation. i.e. if your common sequence is POST login then GET data, the second time login may either fail or return a redirect response or maybe not, it's up to the server.

lainz

  • Hero Member
  • *****
  • Posts: 3766
  • Leandro Diaz
Re: FPHTTPClient speed
« Reply #3 on: September 20, 2020, 03:47:19 pm »
Thanks  :)

 

TinyPortal © 2005-2018