When building a product, it’s important to design it with security, scalability, and reliability in mind. If you don’t have a strategy, your product could fail before it has a chance to grow.
You must answer questions like: How do you scale to millions of concurrent customers without ever having a single service outage? How do you keep your stack and user data secure? How do you monitor and receive alerts? How do you maximize your impact with the least amount of moving parts?
The Traditional Approach
It may seem like a good idea to develop every aspect of a product – build your own everything. Invent your own security. Run the code on a server you control. This mindset opens you up to vulnerabilities, unless you constantly oversee your product. This quickly becomes dollars wasted. Expect to be exposed to vulnerabilities as your product scales. Here are a few topics to consider before you build your product in-house:
- Maintaining Uptime: Today users demand that your product is always available. There’s no concept of ‘closed’ for a mobile app. If you take your API down for maintenance, or make a breaking change, someone will notice and take it out on your customer support. It’s not acceptable to be unavailable.
- Scaling to Handle Traffic: The good news- you went viral overnight. The bad news – our product isn’t scaling like you planned and is not available for most of the traffic. By the time you get it fixed, you’ll have missed the PR bump. You may have lost out on potential customers with no way for recourse. Your product has to adapt gracefully to load changes.
- Security: If you fail to keep data secure you could be subject to data loss and fines. Both could kill your business.
- HIPAA and GDPR compliance: Dealing with user data has strict rules that you must follow and be familiar with. A mistake can result in legal action against you or your product.
The Serverless Approach
A new approach is to offload scaling responsibility to a cloud provider. With this model you will often pay for the resources used by your product on a ‘pay as you go’ basis, also known as “Functions-as-a-Service” (FaaS), instead of buying units of computing capacity. The cloud provider handles most or all of the server administration, provisioning, security, and maintenance. That means your product infinitely scales without managing servers or infrastructure.
More advantages of serverless include:
- Reduced Cost: Pay for what you use and not for idle servers.
- Decreased Time to Market: Focus on building your product and not managing the infrastructure to support it.
- Reduced Latency: Your users are global. Your product should be global. Cloud services operate points of presence across regions delivering a faster and higher quality service to your users.
PubNub’s primary product is a real-time publish/subscribe messaging API built on a global Data Stream Network. A benefit of using PubNub over any other system or homegrown solution is that messages sent with PubNub are delivered in under 0.25 seconds and usually much faster (30 – 40ms) because PubNub has multiple points of presence on every inhabited continent. PubNub supports over 70 SDKs and has features like push notifications and Project EON that you can take advantage of in your product.
Developers use PubNub’s Real-time Messaging for:
- Chat messaging applications
- Real-time updates like GPS location for ride-share apps
- IoT device signaling
- Real-time monitoring dashboards
- Live audience interaction for classrooms and televised events
Using Functions, you can execute your own code every time a PubNub message is sent. This code can be used to augment, transform, route, filter, or aggregate messages. Here are a few things you could use PubNub functions to do:
- Translation – Send a chat app message in English, and the recipient receives it in Spanish.
- Secure API Calls – Trigger an alert when a secure message meets certain criteria – email, text message, tweet, mobile push, etc.
- Network Logic – Tally up millions of votes or question answers during real-time audience interaction.
- Serve Data – Build a globally replicated, low latency, production REST API in 5 minutes.
The Blocks Catalog contains more than 80 open source PubNub Function event handlers, to link your product up to popular APIs. See the Blocks Catalog for free Functions code that you can import to your PubNub app.
Build a Serverless Application
Get started building a serverless application using PubNub with these resources:
- Functions Overview
- Functions Crash Course
- Serverless Token Validation Using PubNub Functions and Vault
- How to Create Microservices and Go Serverless with PubNub Functions
Have suggestions or questions about the content of this post? Reach out at email@example.com.