What does the "async" attribute on policies do?

On policies, one of the attributes on the root element is "async". The docs say it's for internal optimization only. Should this attribute be ignored? Left at the default of "false"? If not, how should it be used?

Solved Solved
3 4 1,438
2 ACCEPTED SOLUTIONS

adas
New Member

@Floyd Jones

I think its a bit of a misnomer. When we say async, it doesn't mean the policy would be executed asynchronously. The internal optimisation that it refers to, if I were to explain that in layman's term - the policy execution is off-loaded to a different thread, while the thread serving the request is free to pickup additional request and come back to the worker thread once the processing is complete. In certain cases, it makes sense to set it to true, but largely it can be left as default. I agree that it would be good to document this in our docs so that its clear to the proxy developers.

View solution in original post

Not applicable

AFAIK we can enable for policies which we think can take more time so that it can improve / not degrade the performance of the whole API and other APIs deployed together and we should also be extra careful in not enabling for too many policies as context switching between threads can be expensive.

@arghya das Any tips around this or any specific cases where you think we should enable it ?

View solution in original post

4 REPLIES 4

adas
New Member

@Floyd Jones

I think its a bit of a misnomer. When we say async, it doesn't mean the policy would be executed asynchronously. The internal optimisation that it refers to, if I were to explain that in layman's term - the policy execution is off-loaded to a different thread, while the thread serving the request is free to pickup additional request and come back to the worker thread once the processing is complete. In certain cases, it makes sense to set it to true, but largely it can be left as default. I agree that it would be good to document this in our docs so that its clear to the proxy developers.

In answering http://community.apigee.com/questions/3250/can-i-use-service-callout-to-send-a-soap-request.html, I debated about whether to suggest the async attribute, but I was unsure. If the user doesn't care about the response but just wants to make an asynchronous call, would this be an appropriate use of async=true?

@Lee Grey Not really, that's the reason I was referring to that attribute as a misnomer. It's async wrt to execution of the particular policy, not wrt the entire request as such. In the other post where you suggested the javascript approach to do a callout to a soap backend, that would work perfectly because javascript execution is truly async.

Not applicable

AFAIK we can enable for policies which we think can take more time so that it can improve / not degrade the performance of the whole API and other APIs deployed together and we should also be extra careful in not enabling for too many policies as context switching between threads can be expensive.

@arghya das Any tips around this or any specific cases where you think we should enable it ?