T
T
Timur Gromov2016-05-11 23:19:45
PHP
Timur Gromov, 2016-05-11 23:19:45

API organization, in which case the load will be less?

I am making an API for one project, the principle of operation is standard:
1. the user accesses a special script via http, passing parameters to it
2. the script processes these parameters for an average of 15 seconds and returns the result The
question is, which of the options for organizing interaction will reduce the load on the server:

  1. один запрос к серверу: держать соединение открытым до момента готовности результата
  2. два запроса к серверу: принять параметры в первом запросе, вернуть уникальный ключ по которому отдавать результат во втором запросе

Спасибо

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
index0h, 2016-05-12
@tmgrom

It depends on the frequency of your 15-second requests. If once a day - the 1st option is optimal. If the frequency of requests is high - 2nd.

R
Rou1997, 2016-05-11
@Rou1997

It is obvious that in the first it is less. You can experiment on a local server and use the task manager to make sure that a long polling loads the server less than a frequent one. Maintaining an open connection by itself does not load the processor at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question