performance insights

Options

I have an endpoint that really has a lot of validations. This is divided into 2

  1. it makes validations of the input data. Approx this validations is taking 3sec (of all the logic of my function stack).
    If the result of this validation is true.
  2. I must send a request to a third party api. when I send this request I get a token back. With this token I must wait 20-30 sec to request to another endpoint the results with the ID that they gave me in the first request.

Here is the question:
Currently in my function stack the user must wait the whole process in one call to my API. i.e. the end user must wait an average of 20-30sec + the logic of my function stack. I feel this is not ideal
vs
using pos progress, if the first step returns true, I send the first request to get the id and finish the request. and in the pos progress I wait the 20sec and finish the rest of the process (which I think is the best option).

--
Do you think this solution is optimal, or what other solution can you recommend?

Tagged:

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    The question is, what does the user need to know is true in order to make their next decision. If in the first few seconds your endpoint can give them confidence that its all paperwork at that point, then returning/post-processing can be good for you. I'd game out a conversation between your user/FE and the backend service. Think of it like going to a store for a slightly more complex transaction, like returning an item. How long do you have to wait? For the article to be verified? For it to be re-stocked? for it to even go to the inventory out back? Do you leave with your money in hand, or is the transaction done with a refund scheduled asssuming the rest is OK? There are multiple "right" answers depending on your policy and how you want that transaction to go.

  • nelson artunduaga
    Options

    Thanks for giving me this point of view, it makes a lot of sense.
    Specifically this endpoint returns some filled documents for the user to print and sign.
    In this first validation we look for the data in our DB, if they are not there we request them to the sources (this is where we have to wait the 20 sec approx) once the data arrives, we fill the documents and return a url for the user to download.
    it might be smarter to finish the request once the first validation is done and do a post-processing. does it make sense to you? ....
    As always, you are a great help! thank you very much! @Ray Deck