winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.95k stars 195 forks source link

Warn about timeouts below 3 seconds for inflight functions #3409

Open skorfmann opened 1 year ago

skorfmann commented 1 year ago

Feature Spec

wing now let's the user know, that timeouts for inflight functions below 3 seconds are likely to run into the given timeouts in cold start situations.

e.g. the following example

queue.setConsumer(inflight (message: str) => {
  bucket.put("wing.txt", "Hello, ${message}");
}, timeout: 1s);

will work for warm inflight functions, but will be killed due to the ambitious timeout setting for cold starts. This can be quite confusing and unexpected. Hence, the wing compiler will now warn about this and recommend a minimum of 3 seconds.

> wing compile main.w
warn: timeout of 1 second detected. Please consider a timeout of at least 3 seconds to allow for inflight function cold starts.
queue.setConsumer(inflight (message: str) => {
  bucket.put("wing.txt", "Hello, ${message}");
}, timeout: 1s);

Use Cases

while short timeouts work in the simulator, this won't work as expected for the tf-aws target.

Implementation Notes

2023-07-13T10:58:19.500+02:00CopySTART RequestId: 7f3ab5aa-07c7-5413-a56e-e883b91d6fb6 Version: $LATEST | START RequestId: 7f3ab5aa-07c7-5413-a56e-e883b91d6fb6 Version: $LATEST
-- | --
  | 2023-07-13T10:58:20.540+02:00Copy2023-07-13T08:58:20.540Z 7f3ab5aa-07c7-5413-a56e-e883b91d6fb6 Task timed out after 1.04 seconds | 2023-07-13T08:58:20.540Z 7f3ab5aa-07c7-5413-a56e-e883b91d6fb6 Task timed out after 1.04 seconds
  | 2023-07-13T10:58:20.540+02:00 | END RequestId: 7f3ab5aa-07c7-5413-a56e-e883b91d6fb6
  | 2023-07-13T10:58:20.540+02:00CopyREPORT RequestId: 7f3ab5aa-07c7-5413-a56e-e883b91d6fb6 Duration: 1040.17 ms    Billed Duration: 1000 ms    Memory Size: 128 MB Max Memory Used: 77 MB  Init Duration: 224.30 ms

This is also depending on the runtime sizing (probably not an issue for larger sized Lambda functions). Perhaps this should be taken into account.

Component

Compiler, SDK

Community Notes

Chriscbr commented 1 year ago

I'd imagine the warning should only appear if you're compiling to a target where cold starts are relevant (e.g. AWS)

skorfmann commented 1 year ago

I'd imagine the warning should only appear if you're compiling to a target where cold starts are relevant (e.g. AWS)

Not sure, since the ultimate goal is likely to deploy to one of the cloud providers? Wouldn't you want to get a hint early in the process?

Chriscbr commented 1 year ago

If we think cold starts are applicable to all cloud providers then I guess it's alright. I just want to make sure we are avoiding giving error messages that don't apply to all cloud providers. For example, if someone wrote a backend for cloud.Function that uses e.g. Cloudflare Workers, then it's possible a 1s timeout might be OK if they have shorter cold starts.

Also if we emit warnings, there ought to be a way for users to turn them off / ignore them.

github-actions[bot] commented 1 year ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

garysassano commented 1 year ago

There are too many variables to consider:

github-actions[bot] commented 6 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 3 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!