aws

http://status.aws.amazon.com/ https://www.expeditedssl.com/aws-in-plain-english
kenny 2020-04-29T16:47:48.140300Z

Is it safe to assume cognitect.aws.client.api/client is non-blocking?

alexmiller 2020-04-29T16:49:53.140700Z

^^ @ghadi @dchelimsky

2020-04-29T16:55:02.141900Z

It reads from the file system.

2020-04-29T17:04:45.142900Z

@kenny does that answer your question?

kenny 2020-04-29T17:07:02.143300Z

I think so. Probably safest to create clients not in a go block then, right?

kenny 2020-04-29T18:29:31.144600Z

I've seen https://github.com/cognitect-labs/aws-api/issues/41 on no current support for timeouts in aws-api. Is there a workaround? This seems like a big hole. Am I supposed to let requests hang around forever if AWS would let them?

ghadi 2020-04-29T18:33:42.145400Z

we're planning on supporting this explicitly, but for now you can use the async API and put an external timeout on your call

ghadi 2020-04-29T18:34:28.146200Z

(async/alts! [aws-response your-timeout])

✔️ 1
kenny 2020-04-29T18:34:42.146500Z

Couldn't this result in lots of resources left hanging though?

ghadi 2020-04-29T18:35:38.147600Z

meaning open http connections?

kenny 2020-04-29T18:35:42.147800Z

Yes

ghadi 2020-04-29T18:36:12.148400Z

right

ghadi 2020-04-29T18:36:21.148800Z

quantifying it will depend on your use-case

ghadi 2020-04-29T18:37:17.149900Z

my guess is that we can/will use the http client library's timeout mechanism

ghadi 2020-04-29T18:37:35.150300Z

what APIs are you using, or is this an abstract question?

ghadi 2020-04-29T18:37:52.150800Z

SQS ReceiveMessage offers a explicit long-polling timeout

ghadi 2020-04-29T18:38:14.151400Z

for example

kenny 2020-04-29T18:40:40.153700Z

Both, I suppose. I slept my computer and went for lunch. When I came back, I ran an API call to AWS lambda with a <!! around the aws-api response. It sat for several minutes with no response. I don't know exactly what caused this, but it made the issue very obvious and quite frightening. If that could happen, it could (we must assume it will) lock up the calling thread for who knows how long. I can, and should, add the alts! but if something like this were to happen often in production, it could easily eat up lots of resources.

kenny 2020-04-29T18:41:23.154Z

(we will be calling this particular api very often)

ghadi 2020-04-29T18:41:48.154200Z

InvokeLambda?

kenny 2020-04-29T18:42:03.154500Z

:op :Invoke

kenny 2020-04-29T18:42:35.154800Z

Like so

(aws-api-async/invoke
  (async/<! @*lambda-client)
  {:op      :Invoke
   :request {:FunctionName   function-name
             :InvocationType "RequestResponse"
             :Payload        (transit/encode-transit query-request)}})

kenny 2020-04-29T18:43:19.155500Z

Well, that's newer. The weird (async/<! @*lambda-client) wasn't there before.

ghadi 2020-04-29T18:43:27.155700Z

if you care about the lambda response, you have to wait for it though

kenny 2020-04-29T18:43:40.156100Z

I care about it but not enough to wait minutes 🙂

ghadi 2020-04-29T18:43:53.156700Z

in that case put a timeout on the Lambda itself

kenny 2020-04-29T18:44:08.157300Z

It should never take that long. After the lambda is hot, it executes in 10s of millis.

ghadi 2020-04-29T18:44:31.157700Z

default timeout is 3 seconds on a lambda

ghadi 2020-04-29T18:44:37.157900Z

max is 15 minutes

kenny 2020-04-29T18:44:53.158500Z

This is a Datomic Ion. Guessing there's some default timeout on it.

kenny 2020-04-29T18:45:14.158800Z

I see 1 min in the AWS console. I waited at least 5 mins.

ghadi 2020-04-29T18:45:37.159200Z

that would be an interesting repro for the datomic team

ghadi 2020-04-29T18:45:53.159600Z

the lambda proxies that Ions spin up have a default 60s timeout

kenny 2020-04-29T18:47:13.160300Z

So for whatever reason, it sat for 5 mins before I restarted the REPL.

2020-04-29T19:26:35.160500Z

I bet this isn't an http timeout issue at all, my guess is a deadlock core async threadpool

kenny 2020-04-29T19:27:41.160700Z

Certainly possible. From the REPL history, I had only ran the code 3 times: twice before lunch and the 1 after. That wouldn't deadlock the threadpool, right?

kenny 2020-04-29T19:28:20.160900Z

This code is also incredibly simple. No obvious blocking calls.

2020-04-29T19:29:24.161100Z

It depends on what other code is running. You can look at thread dumps or manually schedule a job on the core async threadpool to see if it runs

2020-04-29T19:32:43.161300Z

The async API will also retry operations with some kind of backoff for certain errors

kenny 2020-04-29T19:33:24.161500Z

That could have brought the total time to return above 5 mins if the Lambda kept timing out.

2020-04-29T19:34:13.161700Z

It doesn't tell you if that is happening, but you can configure that stuff when creating a client, so you could pass it a function that logs something