Giter VIP home page Giter VIP logo

Comments (4)

lambrospetrou avatar lambrospetrou commented on May 25, 2024 1

@cristim You are right! I was confused with something else to be honest on Lambda. Cool, then this package is exactly what I was looking for;p Thanks

ps. Although I would still make the vars private/local instead of global to keep the stateless feature clear;p

from archive_aws-lambda-go-net.

cristim avatar cristim commented on May 25, 2024

That's just how Lambda works internally.

Lambda executes the code in a container that is started fresh or resumed for each and every invocation and then paused once it is done, but a single function call is running in the container at a given time.

When the function is called at a high enough rate, the runtime instantiates more such containers, and schedules the runs there in order to handle the extra load. The idle containers get destroyed after a period of inactivity.

See the documentation for more details.

from archive_aws-lambda-go-net.

fsenart avatar fsenart commented on May 25, 2024

@lambrospetrou there are two aspects when running in the AWS Lambda environment:

  • Executions are isolated: one and only one request is handled at any time.
  • Executions should be stateless: goroutines must complete before the code exits.

I admit that these aspects are weird to deal with. Mostly the second one as we have noticed very strange behaviors when goroutines does not complete before exit.

That being said, this project aims to provide a net listener for AWS Lambda. As such, it should behave like a net interface which respects the two above aspects. So we have a blocking channel to start the processing and a blocking channel to ensure that we won't exit before an answer is returned from the user handler (as Go http package internally uses goroutines).

For the other part of your question concerning the private/local vars instead of global vars, this is more a matter of design. In usual cases, you would probably never code something like this, but in AWS Lambda it is more acceptable.
To comply with above two aspects, one need to have some kind of "coordinator". In the case of AWS Lambda global state (along with this bunch of global variables) does the job, simply.

PS: At the time being, the project still uses the first version of our Go shim https://github.com/eawsy/aws-lambda-go. But we've recently released a new version which leverages Go 1.8 plugins https://github.com/eawsy/aws-lambda-go-shim. Also, in the next coming days, we will migrate this project to use the new version of the shim. The code should become more simple and clear, and we will try to take into account your remarks. Keep connected ;)

from archive_aws-lambda-go-net.

lambrospetrou avatar lambrospetrou commented on May 25, 2024

Great news;p I will go over your new package (....go-shim) although it seems a bit more complicated than the existing one.

I will keep an eye.

from archive_aws-lambda-go-net.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.