fabric8-analytics-server icon indicating copy to clipboard operation
fabric8-analytics-server copied to clipboard

Please specify timeout for the Prometheus service HTTP POST call

Open tisnik opened this issue 6 years ago • 8 comments

https://github.com/fabric8-analytics/fabric8-analytics-server/blob/a9330f79207c795366a0f04001b82219d7d73f5f/bayesian/api_v1.py#L272

Most requests to external servers should have a timeout attached, in case the server is not responding in a timely manner. By default, requests do not time out unless a timeout value is set explicitly. Without a timeout, your code may hang for minutes or more.

tisnik avatar Jul 08 '19 07:07 tisnik

It's an async future requests call. API server does not wait for response. Closing this.

miteshvp avatar Jul 08 '19 07:07 miteshvp

@miteshvp is not this session used to call workers asynchronously? I'd suggest to use second FutureSession instance for calling Prometheus

tisnik avatar Jul 08 '19 07:07 tisnik

Actually, its threaded. https://github.com/fabric8-analytics/fabric8-analytics-server/blob/master/bayesian/api_v1.py#L81-L82 so we don't need any other session.

miteshvp avatar Jul 08 '19 08:07 miteshvp

Yup, I meant that we might need to increase the number of workers for the futuresession?

tisnik avatar Jul 08 '19 08:07 tisnik

@tisnik - I guess 100 is a good enough number for our requests. These sessions are not used to invoke workers at the moment. Workers are invoked via another async flow https://github.com/fabric8-analytics/fabric8-analytics-server/blob/master/bayesian/api_v1.py#L278 I guess we are good here.

miteshvp avatar Jul 08 '19 08:07 miteshvp

Yup, and what timeout value to choose? In this case it might be let's say from one to five seconds at most. WDYT?

tisnik avatar Jul 08 '19 08:07 tisnik

@tisnik - this is like a nano-sec call. Timeout doesn't make sense here

miteshvp avatar Jul 08 '19 11:07 miteshvp

@miteshvp yes - in case everything is working as expected. But in reality we'll see network issues that would need to be handled by our service. We can discuss in in a chat rather than there ;)

tisnik avatar Jul 08 '19 12:07 tisnik