4
16 Comments

When do you switch to serverless solutions like AWS, GCP...

Hi guys,

I recently discoverd the world of SAAS applications but I still don't have a grasp on the architecture of such apps.

Given that I develop using MERN stack and host my apps using Firebase, when should I consider solutions like AWS or GCP for my future SAAS...

Thank you.

  1. 3

    You can keep using MERN stack and go 100% serverless with Mongo Atlas + Google Cloud Functions/AWS Lambda for express app. AWS products have a steeper learning curve compared to GCP. I prefer GCP. I read somewhere that Firebase hosting is pretty fast compared to other cloud solutions but I haven't tested.

    Going serverless generally means less headache with scaling, you can focus more on development. Also you don't have to pay until your usage per month fits into the free quota.

    1. 2

      Mongo Atlas is not a good fit for serverless projects unless you're going for the bigger (more expensive) tiers.

      Atlas has pretty severe connection limits on the cheaper plans:

      https://docs.atlas.mongodb.com/reference/atlas-limits/

      Also: https://www.infoq.com/news/2020/05/Jepsen-MongoDB-4-2-6/

      Better options would be Dynamo, Fauna, or Cosmos.

      I read somewhere that Firebase hosting is pretty fast compared to other cloud solutions but I haven't tested.

      I did benchmark some static hosts and Firebase wasn't exactly among the best:

      https://www.pierbover.com/posts/static-hosting-benchmark-2020/

      1. 2

        That was a totally awesome article, thank you for sharing.

    2. 1

      What actually is serverless? I'm not technical but if you're hosting your software/anything on a server doesn't that mean we're on a server and by what definition one can call that serverless??

      1. 1

        Serverless is also know as function-as-a-service. Basically you only deal with the code that executes (the function) and pay only for the execution time of that function (and allocated resources).

        This allows you to save money because you don't pay for server idle times anymore, and also make your life easier because you don't have to setup servers, install stuff on them, monitor the app, etc.

        But you lose a lot of control in the process (usually serverless services restrict you to some specific runtimes, such as specific versions of a language) and you need to write the code using their recipes (eg. for AWS Lambda, for Python functions you need to have a "handle" function with some specific parameters, depending on what triggers that function you get the data in a very specific format, and you need to return the response in a very specific response as well). This creates vendor lock-in and it will be harder to move away from it once you reach a certain scale.

    3. 1

      What about hosting the full app on Heroku in order to have full control. Especially that I have zero experience with AWS and GCP solutions.

  2. 2

    SaaS doesn't really mean anything in terms of architecture. Different products will have different requirements.

    Different serverless products serve wildly different purposes and have pros and cons. AWS Lambda is not the same as FaunaDB or Google Cloud Run.

    My advice is to start by analyzing your problem and then pick the right tool for the job. Don't put the cart before the horse. If MERN solves your problem, then use that.

  3. 2

    Every firebase project is a GCP project under the surface. When it's required, you can easily transition to GCP. If you are already on firebase, you are on right track, I believe. https://medium.com/google-developers/whats-the-relationship-between-firebase-and-google-cloud-57e268a7ff6f

  4. 1

    FWIW I use a hybrid approach. My main app is a Rails app hosted with Heroku. The Rails app is responsible for all the usual SaaS stuff: user auth, CRUD, receiving webhooks, managing the job queue, etc.

    For any piece of functionality that is both highly specific, would bloat the main codebase, and could live separately - that's when I turn to serverless. I have a few AWS Lambda functions that my Rails app calls when needed.

    I will echo some other comments here: SaaS is just a business model. Your architectural decisions are not defined by your business model, they are defined by the technical problem you are solving and the way you want to deliver that to customers.

    If you are just starting out and your tech requirements are similar to other MVPs, personally I don't think there is any benefit to experimenting with serverless. I would stick with a monolith and then as you add more functionality, start to evaluate whether serverless is appropriate.

  5. 1

    AWS, GCP, IBM Cloud and Azure are cloud service providers and their serverless solutions include AWS Lambda or IBM Cloud Code Engine. Serverless means you don't have to actively manage Kubernetes configuration and worry about scaling up/ scaling down of a particular application. You can break down your application in to smaller functions and each function can be its own independent app. The advantage of serverless is scales down to 0 when there's no load on application. So you truly pay for what you use. If your application's load expectation is intermittent then this is a great solution. It is also great solution in terms of cost: time and money because you don't have to spend time learning kubernetes or spend money to hire someone who can do it for you. Also, it allows you the flexibility in terms of scaling only functions that would experience more requests rather than scaling whole application.. so in a way I guess what I am trying to say is serverless does effectively allow and kind of entice you to follow 12 factor microservice architecture.

    let me know if that helps!

    1. 1

      Thank you.
      Can you give me recommandations regarding the learning curve and wich platform to choose if I want to switch to serverless architecture.

      I have another question: Does switching to these platforms mean I should abondon my backend code ( express + mongo) in order to learn platform specific technologies, like AWS Dynamo DB?

      1. 2

        you don't have abandon express because nodejs is supported by almost all serverless platforms.. you will need to look at the documentation of these services say AWS Lambda or IBM Code engine to learn if they allow you to connect your mongo collections to particular functions in an event driven way.. I will be shocked if they don't.. Also, the learning curve is not that great.. you should be able to ramp up pretty quick.. I think within a month or two.

  6. 1

    You wouldn't benefit much from switching to serverless with such a traditional stack as MERN. A better serverless stack would be something like DERN - DynamoDB, node web app running on Lambda, and the frontend hosted on S3, all that running behind Cloudfront. But your choice of MERN is perfectly fine and you don't have to switch.

  7. 1

    Where are you keeping your mongodb on firebase?
    Cloud services like aws and gcp tend to have a pretty expensive price for cpu and memory due to the crazy amount of functionality and reliability that comes with them and firebase is even more expensive since it's yet another managed service on top of gcp.
    So I would say when you see firebase price is sky rocketing then it's time to move on.
    I also recommend to put your domain on something like cloudflare to avoid consuming your daily quota for firebase hosting too fast.

    1. 1

      Thank you .
      For my DB it's hosted using mongodb atlas I guess.

      I understand now that switching is relative to the scale of my app.

      If we suppose I have 100 users, where in a typical SAAS is the most power and memory consumed...?

      1. 1

        It purely depends on what your application does.
        If express just makes simple queries then process the data then you have more load on express.
        If you do complicated queries then it would be on mongo.
        Anyway 100 users consume nothing to be honest. I have hosted a game with 80 users connected with websocket one a server with 1 vcpu and 2gb of ram.
        If you know a little bit about preparing a server I would definitely recommend you going for something like dokku on hetzner to save lots of money.
        You can easily scale up to 1000 users there without worrying much.

Trending on Indie Hackers
How I grew a side project to 100k Unique Visitors in 7 days with 0 audience 49 comments Competing with Product Hunt: a month later 33 comments Why do you hate marketing? 29 comments My Top 20 Free Tools That I Use Everyday as an Indie Hacker 17 comments $15k revenues in <4 months as a solopreneur 14 comments Use Your Product 13 comments