![[Series 2: Leveraging BaaS] Serverless vs. BaaS? End the Debate with an “Embedded Compute” Strategy](https://cdn.prod.website-files.com/673aa52d830b9cdde55908fd/696f0f67ceac65d77c5f1a3d_image.png)
Have you ever felt frustrated because building every piece of logic with Serverless (FaaS) made your architecture feel too fragmented? Or conversely, have you felt trapped using a Backend as a Service (BaaS) because you couldn't find a clean way to implement complex business logic?
Viewing BaaS and Serverless as an "A vs. B" rivalry often hinders our understanding of modern backend design. Today’s BaaS has evolved far beyond simple data storage; it has internalized the Compute layer—traditionally the domain of Serverless.
The question is no longer "Which one should I use?" but rather "Where do I draw the line between built-in BaaS features and external compute?"
Modern BaaS platforms provide more than just a state layer (DB, Auth, Storage). They now offer a compute layer to execute custom logic natively.
We can now redefine the architectural stack into three distinct tiers:
Core Principle:
"Keep the State in BaaS and handle the Rules with Compute. Always prioritize Embedded Compute before reaching for external tools."
When working with BaaS, developers often confuse "Realtime Data Updates" with "Server-side Logic Execution." They serve entirely different purposes.
By distinguishing between "Realtime Sync" and "Server-side Event Execution (Functions)," you can significantly reduce communication overhead within your team.
In a BaaS environment, the default approach is for the client to update the BaaS database directly. Thinking that "Serverless must write to the DB on behalf of the client" often adds unnecessary complexity.
If a Compute function needs to write to the DB, it shouldn’t be because the DB is "inaccessible" to the client, but because of Trust and Integrity.
While prioritizing built-in features is best, you must be aware of the technical trade-offs:
In a BaaS-centric design, the goal is to use Embedded Compute as the default and External Serverless as an expansion option.
Characteristics: Requires low latency, short execution time, and fits within platform constraints.
Characteristics: Long-running tasks, high CPU/Memory usage, or native OS dependencies.
Characteristics: The embedded function acts as the "Orchestrator" (validation/triggering), while the external serverless acts as the "Worker" (heavy lifting).
Real-world Workflow:
Pro-tips & Alternatives:
1) Callback Pattern: While the Worker usually records the done status, you might encounter security constraints where granting DB write access to an external worker is difficult. In such cases, have the Worker send a callback (webhook) to the BaaS Embedded Compute, letting the internal function handle the final status update.
2) External Storage: Depending on file size, cost-efficiency, or data retention policies, you may choose to upload Worker-generated files to external object storage (like AWS S3) instead of the built-in BaaS Storage.
BaaS and Serverless are not competing technologies. In fact, the current trend is BaaS absorbing Serverless to become a more powerful, unified platform.
The most practical architectural advice is this:"Start Small, Scale Smart."
Don't struggle to build a massive external infrastructure from day one. Entrust your State to BaaS and start your Rules with Embedded Compute. When your service grows and hits the limits of those built-in features—that is the perfect time to scale outward.