fnproject / fn

The container native, cloud agnostic serverless platform.
http://fnproject.io
Apache License 2.0
5.73k stars 404 forks source link

clamp down user API around container system parameters to fix around memory #1106

Open rdallman opened 6 years ago

rdallman commented 6 years ago

at present, we allow a user to set cpu, memory, and tmpfs_size on a given function (tba 'network'). this allows variable amounts for any of those given parameters where they are independent of one another. quite simply, this issue proposes to base the settings for any other system resources that exist currently or in the future off of memory alone. first, illustrated with an example (these are not in any way prescriptive):

where a user would only set and/or see the memory setting, and all of the other settings would get applied under the hood for that function (not visible to the user via API). part of the work to do this / make this capable has gone in https://github.com/fnproject/fn/pull/1065 with the current API intact, this aims to round this out a little more.

lambda's copyright around this is as follows, if this helps to clarify:

You only specify the amount of memory you want to allocate for your Lambda function. AWS Lambda allocates CPU power proportional to the memory by using the same ratio as a general purpose Amazon EC2 instance type, such as an M3 type. For example, if you allocate 256 MB memory, your Lambda function will receive twice the CPU share than if you allocated only 128 MB. You can update the configuration and request additional memory in 64 MB increments from 128MB to 3008 MB.

benefits:

cons:

rdallman commented 6 years ago

cc @shaunsmith @skinowski

shaunsmith commented 6 years ago

+1

Note that Google Functions may bill for both GB and GHz but the user only selects GBs. The relationship between GBs and GHz is fixed. IMHO this is simply pricing obfuscation.

zootalures commented 6 years ago

My thinking here is that CPU ought to somewhat configurabile/pluggable - either at the LB ingress point (i.e. one policy for all functions) or at the agent itself (policy based on specific host configuration - you get what we got, based on the host, maximise usage of specific hosts)

/tmp (we keep saying tmpfs but actualy I don't see a necessity that this is actually a memory-backed tmpfs, could be e.g. a loopback on disk) probably ought to be uniform (even if it's proportional to RAM ) across the system but also configurable as it represents a much harder constraint on the function implementation rather than CPU - when I target a particular platform I want to know how much /tmp I'm going to get.