In the world of web development, deploying your projects quickly and efficiently is crucial. Vercel, a popular platform, has made this process a breeze for many developers. However, Vercel isn’t without its limitations, especially when it comes to API execution time. In this blog post, we’ll explore SST as an alternative that offers Infrastructure as Code (IaC) and direct deployment to AWS.
What is Vercel?
Vercel is a cloud platform that streamlines the development and deployment of web applications and websites. It boasts an intuitive interface and offers a range of features, including serverless functions, static site hosting, continuous deployment, global content delivery, and collaboration tools. To add a project to Vercel, follow these simple steps:
- Sign in to your Vercel account or create one if you haven’t already.
- Connect your project’s Git repository to Vercel.
- Configure your project settings and choose your deployment branch.
- Vercel will automatically build and deploy your project.
API Time Limit
One of Vercel’s primary limitations is its 10-second API execution time limit. While this restriction suits many use cases, it can be a significant hindrance for applications that require longer processing times or perform complex computations. If your project involves heavy server-side processing or data crunching that exceeds this time limit, Vercel might not be the ideal choice.
Vercel’s pricing structure is based on usage, and while it can be cost-effective for small to medium-sized projects, it may not be the most budget-friendly option for very large applications or websites with high traffic. The usage-based model can lead to higher costs as your project scales, potentially limiting its affordability for larger endeavors.
No Direct Control Over Infrastructure
Vercel’s user-friendly platform abstracts many of the underlying AWS infrastructure details, which simplifies deployment but can limit your ability to fine-tune AWS resources. If you require precise control over your AWS environment or have specific infrastructure configurations in mind, Vercel may not provide the level of customization you need.
An Alternative - SST
SST is a tool designed to simplify the development of serverless applications on AWS. It addresses challenges associated with working directly with AWS Lambda, Amazon API Gateway, and other AWS services by enabling developers to define their infrastructure using AWS CDK, facilitating live testing and debugging with various IDEs, and offering a web-based dashboard for app management.
SST aims to streamline the process of creating and deploying serverless applications, supporting multiple programming languages for Lambda functions and higher-level constructs tailored for serverless development.From the SST docs “SST converts your infrastructure code into a CloudFormation template using AWS CDK” as seen in the figure below.
AWS CloudFormation is a service provided by Amazon Web Services (AWS) that simplifies and automates the process of provisioning and managing AWS resources. It allows developers and system administrators to define their infrastructure as code using templates, typically in YAML or JSON format. A drawback is lengthy templates that require manual definition of even minor resources, and it poses challenges for code reuse. And its use of YAML and JSON can also complicate handling large templates and requires a steep learning curve for resource definition.
SST simplifies serverless app development using higher-level CDK constructs, offering customization and a local development environment, integrating commands like “sst build” and “sst deploy”.
SST File Structure
There are two types of file structure when it comes to using SST in a project, Drop-in Mode and Monorepo.
In drop-in mode, SST can be used as part of your frontend app. For example, if you run npm create sst inside a Next.js app, it’ll drop a sst.config.ts in your project. This is great if you have a simple Next.js app and you just want to deploy it to AWS with SST. The directory structure in drop-in mode might look like this:
my-nextjs-app ├─ next.config.js ├─ sst.config.ts ├─ package.json ├─ public ├─ styles └─ pages
A monorepo setup is recommended as it’s the best way to manage a growing project with interconnected parts like the backend, frontend, and infrastructure. In this structure, you can add your frontend to the packages/web/ directory, packages/functions/ are for backend functions, packages/core/ is for any shared business logic, and stacks/ has your infrastructure definitions. The directory structure in monorepo mode might look like this:
my-sst-app ├─ package.json ├─ sst.config.ts ├─ packages │ ├─ core │ │ └─ migrations │ ├─ functions │ ├─ graphql │ └─ web └─ stacks
Key Advantages of SST
The advantages of SST are significant:
- No API time limits: You can execute tasks that require longer processing times without constraints.
- Full control: Manage your AWS resources with precision and tailor your setup to your project’s specific needs.
- Integration with AWS: Seamlessly incorporate AWS services like DynamoDB, Lambda, and API Gateway.
In summary, if you prioritize rapid development without the burden of resource management and are willing to potentially incur costs, Vercel is an excellent choice. On the other hand, if you have the time and desire to exercise full control over your AWS resources and services, paying only for what is utilized, learning SST is a valuable and worth the investment to learn. The choice ultimately depends on your specific project requirements and development preferences.