Live data from Hacker News

Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

aws.amazon.com

71–80 of 140 posts

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#71
post #3

Listen folks - it's still a fantasy. Latency is still 5s on many requests = no deal. This has been going on for years. Would someone form AMZ please stand up? I suggest that the latency is 5s for the 'first call', then, subsequent calls are fast - and if you don't use your lambda for a minute or so, it goes back to having latency. I suggest maybe this has something to do with loading it into memory when it's used? Th…

If you are serving high traffic then what's the problem? If your product has only occasional use then you trade cost for latency; spin up an ec2 instance if your request times exceed a few minutes call

You could have certain requests that don't come that often, even on a high traffic site. And if you don't know for how long lambdas stay hot, how are you supposed to time it? Even a call every few minutes may not be enough to keep them hot.

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#72

Wherein "serverless" basically means more computers in more places just doing different tasks.

Yep. It's good old fashioned webhosting. Drop your files in the amazon equivalent of ~/public-html/ . If it serves your needs, it's not a bad thing, but it's hardly revolutionary.

Is there any other service where I can run arbitrary code and be billed in increments of 100ms or less?

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#73
post #70

Earlier quoted context omitted.

Write code to run on? a server.

Call it whatever you want, but I like to use the language of those who hold the purse-strings. If they call it "serverless", then I call it "serverless". If delivering a lecture about why it's not really serverless improves your product, then go ahead and deliver that lecture, but I doubt it will.

Involves a server listening on a port, running on infrastructure that you indirectly pay. Not in the air, on a server.

It is a very misleading term. Especially for non-tech savvy. Sounds like a scam.

It's like calling being passenger on a car "wheel-less transport", because I as passenger don't have wheels.

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#74

I hate the term serverless. It involves a server. AWS Lambda is a service bound to a port therefore a server. It runs user defined functions, true. But it is a server.

It would help if people referred to this technological concept as Function as a Service . That is a lot less ambiguous and buzzwordish than 'serverless'.

[deleted]

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#75
post #67

I am currently using AWS API Gateway + Lambda for the serverless backend of a social traveling startup. It is absolutely awesome: we are few people in IT and it is amazingly simple to manage the whole stuff. Moreover imho they are mature services at this time, they are flexible enough with enough configuration properties to fulfill a nearly full control of the development experience.

How much does it end up costing you? Any ideas how much a 'traditional' setup would be in comparison?

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#76

I'm always surprised at the lack of discussion around database connection reuse with AWS Lambda. It's a pretty big deal that every single API call requires a new database connection. The only solutions I've seen so far are to run a separate app to interface with the database, or moving the connection outside of the handler (which still has issues). Am I missing something or is everyone just really happy to use Dynamo…

I am curious what sort of stuff is being built that need microservices (presumably so they scale) yet still has a database back end (usually the IO is the bottleneck in most applications).

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#77
post #26
post #11

I love lambda's, but api gateway was far from mature the last time I used it (6 months ago). Unless they have made serious updates to the deployment workflow, feature set, and documentation I would not recommend building your products on it.

The "0 to 1" workflow right out of AWS could not be easier, they have an in-browser code editor with a hello world already written for you. But that workflow doesn't make sense for real dev teams. So there's https://github.com/serverless/serverless . It's driven by a yaml file and is intuitive. The only thing I'm bothered by is lack of environment variables (have to hard code them) and terrible API Gateway latency -…

For js projects you can work around that problem with

const config = require('./config.json');

Then you do config.secrets.apiKey etc

You have to gitignore config.json and include it in serverless.yml

Other languages might have to read and parse that JSON into one of their data structures.

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#78

I hate the term serverless. It involves a server. AWS Lambda is a service bound to a port therefore a server. It runs user defined functions, true. But it is a server.

"serverless" is the pricing model as far as i can tell

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#79

I'm always surprised at the lack of discussion around database connection reuse with AWS Lambda. It's a pretty big deal that every single API call requires a new database connection. The only solutions I've seen so far are to run a separate app to interface with the database, or moving the connection outside of the handler (which still has issues). Am I missing something or is everyone just really happy to use Dynamo…

DynamoDB is not immune from that problem. There is no way out: if the container is terminated the connection goes down. The key is not making Lambda stop and rm the container (in docker terms). If there are enough requests the container is reused and the connection stays up, but you must initialize it outside the function. An example with DynamoDB

    const AWS = require("aws-sdk");
    const docClient = new AWS.DynamoDB.DocumentClient();
    module.exports.theFunction = (event, context, callback) => {
      var params = {
        TableName: "table",
        Item: {
            "attribute": "value"
        }
      };
      docClient.put(params, function (err, data) {
        ...
      });
      callback(null, {...});
    };
I didn't try but it should work with any other db.

However, is Lambda cost effective for services with the amount of requests required to have their containers almost never terminated?

Re: Going Serverless: Migrating an Express App to AWS API Gateway and AWS Lambda

#80
post #70

Earlier quoted context omitted.

Call it whatever you want, but I like to use the language of those who hold the purse-strings. If they call it "serverless", then I call it "serverless". If delivering a lecture about why it's not really serverless improves your product, then go ahead and deliver that lecture, but I doubt it will.

Involves a server listening on a port, running on infrastructure that you indirectly pay. Not in the air, on a server. It is a very misleading term. Especially for non-tech savvy. Sounds like a scam. It's like calling being passenger on a car "wheel-less transport", because I as passenger don't have wheels.

A driverless car has a driver, it's just not a human driver. A serverless architecture has servers, but you never see or need to think about them.

Don't get hung up on the name. Bananas are not a fruit, but it's fine to put them in a fruit salad.

Post reply on HN