Meteor Serverless with Lambda

Hey guys,

I just finished a project with very little server requirements (only a couple of methods) and would like to try something new here: Adding these functions to AWS Lambda and calling them through HTTP from my serverless-deployed app.

I’ve read all documentation I could find and some blog/forum posts about it, but still couldn’t figure how to proceed.

Can anyone give me a short (step-by-step) explanation on how to do this? Could be very useful to other developers as well since serverless is quickly becoming a very hot thing.

Thanks!

I have been using serverless framework and a fork of this repo to start all my serverless projects. You might want to try it out. It has all you need to start working and even testing locally your endpoints.

I dont use for the kind of use case you are mentioning, but only for offloading expensive tasks from our main servers. This repo will help you get started.

I’d advise against using Meteor in lambda - Meteor’s startup time is fairly long, and lambda by design has short running requests, where you are charged per 100ms of compute time, including that spinup time. It’s also worth noting that your API will be delayed until Meteor has started, and multiple parallel requests will never be sent to the same lambda “server” (though subsequent requests might be).

That being said - there is nothing to stop you writing your Meteor method as a lambda function, or a generic piece of code that could be called from a Meteor server or Lambda. In general I’d advise you setup lambda@edge using cloudfront, as this is the easiest (and cheapest) method of invoking lambda functions directly (you access it from the cloudfront distribution URL). With the added benefit of being able to cache the results if you want.

However, connecting lambda@edge with a DB can be tricky, as the lambda function will run in multiple data regions. If you find the setup too arduous, you can run lambda “as is” (e.g., not at edge) but you’ll need to configure the API gateway, which has it’s own cost associated with it.

Are you hoping to use lambda for more than just “method calls”? e.g., HCP?

3 Likes

AWS lambda have better performance using GOLANG.

2 Likes

If you want your backend serverless, why not just use plain NodeJS in combination with Lambda and something like Next.js for the front-end?

Or Amazon Amplify which aims at doing something similar like Meteor, but with tight integration with a serverless backend: Full Stack Development - Web and Mobile Apps - AWS Amplify

Pushing a whole Meteor deployment to Lambda seems to be “overkill” to me. Especially as Lambda function calls are prized on execution time.

I recommend using the servlessframework, which helps a lot with deployments:

2 Likes