Author: Barry Luijbregts
We are streaming LIVE now on Twitch. Join us!
When you’re developing applications for the cloud, you need different skills and a different mindset than when developing applications for on-premises environments. This is because the cloud provides massive global scale and resiliency, plus services and features that aren’t available on-premises. To deal with this new world, you need to rethink some of your existing skills and acquire new ones.
Here are the 9 essential skills you need when developing software for the cloud, with a special focus on developing applications for Microsoft Azure.
1. Develop for unpredictability
Unpredictability? Isn’t the cloud supposed to be stable and highly available? Yes, but in getting high availability and other benefits from the cloud, you don’t have control over the server on which your application is running. That’s where the unpredictability comes in.
When you run an application in Azure (let’s say on an App Service Web App), it runs in a Microsoft datacenter on a server. Even serverless applications run on servers—everything does. But Azure is in control of the servers and uses internal services, like its Service Fabric, to run your application, which results in a 99.95% uptime. Sometimes Azure decides that the server running your app is going to fail in the next hour or that your app is probably better off running on a different server for performance, so it will move your app to another server.
You don’t know where your application is running, so you shouldn’t use the local memory, local registry and local file system to store and cache. It’s possible you scale and can’t access the files anymore because you’re running on a different server. Instead, use external services to store data and do caching like Azure Storage or Azure Redis Cache. This way you always know that your data is available, no matter what happens to your app or the server that runs it.
2. Develop with costs in mind
In the cloud, you pay for what you use (most of the time). There are also many services that run all day, regardless of whether they’re being used. In any case, you should be mindful about the costs of your applications. This means being mindful about using CPU cycles, memory, storage and bandwidth.
Think about bandwidth
Consider this example: You want to migrate a system that has an on-premises SQL Server to an Azure SQL Database (the Azure equivalent of SQL Server). After changing all of the connection strings of the applications to the new database—including some of the applications still running on-premises—the next step would be to move those to the cloud. You may think all is well, until you realize that one of the on-premises applications copies the complete database to its memory to crunch the data, every hour.
In Azure, you pay for outgoing data (outgoing traffic is called egress; incoming traffic is called ingress), so if you’re not watching bandwidth, you may find an unexpectedly high bill at the end of the month.
Think about performance
You must be mindful of the CPU and memory that you consume, in addition to data. For example, when you’re using an Azure Function, you get billed for the amount of processing time and power it takes to execute your function (see the details here). This means that if you have a slow function that consumes a lot of CPU cycles and memory, you’ll pay more. Especially when you execute millions of them a month.
Scale your services down and turn them off
Besides making your applications efficient, you can also save costs by scaling your services down; you can turn off or scale down VMs when you are not using them. Or scale your App Services to a cheaper pricing tier and fewer instances when the load is low. The ability to scale down and scale in is what makes the cloud flexible and cost effective.
3. Scale your applications
The cloud makes it easy to scale your applications up, down, out and in, so you can easily move to a more powerful server (scale up) and increase the amount of application instances (scale out), and vice versa (scale down and in). You can do all of this with a press of a button. Smart people have done the hard work so that we don’t have to think about building web farms anymore. Now, we just click and move a slider up and down.
The platform scales easily, but does your app scale as well? That’s up to you. You need to make sure that when you create a new instance of your app, it keeps running. This means that you have to think about things like state in your application. Where do you store that (if you store it at all)? And what if you scale globally? What if you have an application instance in the United States and one in Asia? How do you route your users to the right application instance? Your application needs to be able to deal with multiple instances and you need to design for that.
For challenges like scaling globally, Azure can help. Azure has a service called Azure Traffic Manager that can route users to the most performant application instance for them based on where they are. You can learn more about how this service works in the Building a Global App with Azure PaaS course.
4. Scale your data
When you scale your applications, you also need to scale your data. This is more difficult than scaling your applications because you need to think about:
- Where the data is allowed to be stored
- How you can get the data close to the users to minimize latency and maximize performance
- How to deal with transactional consistency
These are difficult challenges and the solutions depend completely on your situation, like who your users are, where they’re situated, what type of data you store, what the company rules and regulations are and so on.
Azure offers some help with its Azure Cosmos DB service. This enables you to easily replicate data to other regions and choose the level of transactional consistency that you need. However, this might not be a fit for you if your data isn’t allowed to be stored in every location that you want your data to be.
In that case, you should look at sharding your data, so that some of it is in one region and some of it is in another region. Azure can help with Azure SQL Elastic Database Pools and the accompanying Elastic Database Tools.
5. Create a monitoring and diagnostics pipeline
In the cloud, you’ll often end up running many different services that make up your system. Maybe you’re working with microservices that each run in a container in the cloud, talk to databases and use a security service like Azure Active Directory. The loosely connected and distributed nature of the cloud makes it difficult to get a good overview of what’s running and understand the health of your system.
You need to create a pipeline to monitor your services and diagnose them if needed. Luckily, this is plumbing that Azure provides for you. In Azure, you can use the Azure Monitor service to get a good overview of how things are doing. Each service and piece of infrastructure can be instrumented with a deeper logging mechanism like Application Insights for applications and Log Analytics for infrastructure. And when you need diagnostics, you can debug your apps from Visual Studio and even debug in production with the Snapshot Debugger.
Although these services help, it’s up to you to implement all of the applications that you need to monitor and to create an overview of their health.
6. Develop for resiliency
The cloud is built for resiliency. This means that it ensures your applications keep running—even when a server dies. In order to provide this resiliency, the cloud utilizes some mechanisms that you need to be aware of and take into account in your applications.
Most of these mechanisms come down to self-preservation. When an Azure SQL Database is busy processing queries, it will throttle incoming requests so that it can continue to run and not shut down. This means that your call to the database might fail because Azure SQL won’t let it through. This state is temporary. When the Azure SQL Database is no longer busy, it’s able to take on new requests and process them. This is how it stays alive and healthy.
Your call to the database might also fail when the platform decides it needs to process fewer requests from you in order to process more requests from another customer (when you are on a pricing tier that shares hardware). The solution to this is simple: retry your calls to external services by implementing the Retry Pattern covered in the Cloud Design Patterns for Azure: Availability and Resilience course. For Azure, most of the SDKs have the retry pattern implemented, but it’s helpful to know about it and, if needed, customize the retry mechanism.
7. Script your environments
In the cloud, it’s important to script your environments, so you have them as code (infrastructure as code). When you have a script that can create and update your complete infrastructure, you can easily tear everything down and build it back up again when needed. This allows you to only pay for your infrastructure when you use it.
The same goes for when disaster happens. If your environment(s) are gone because a data center failed, you can easily get back up again with the exact same environment as before.
It’s also useful to have your infrastructure as code so that you can deploy and update it automatically. In Azure, you can use the Azure Resource Manager (ARM) templates to create code from your infrastructure (or vice versa) and deploy it using Azure Automation or tools like Visual Studio Team Services.
8. Choose the right services
This is an essential skill, but a difficult one. The cloud consists of many services; in Azure there are over 90 main services that each have a variety of features. From these services, you need to pick the right ones to run your application on, store your data in, secure your app with and so on.
Even if you are not a software architect, you still need to know why to pick one service versus another. You can start by thinking of the amount of control that you need. Maybe you need to be able to log into to a VM and change registry settings to run your app. Or maybe you’re fine with letting the cloud platform do everything for you. The answer will determine which service category you’ll want to use and filter the services to pick from.
There are many more aspects to picking the right services for your applications. You can check out the Microsoft Azure for Developers: What to Use When course to review the service categories in Azure (data, security, monitoring, etc.) and select the right ones for your needs.
9. Focus on building things that matter and let the cloud deal with plumbing
This may be the most important skill that you need when developing applications for the cloud. As developers, we tend to want to create things and have control over them. Some may feel compelled to create their own object relational mappers and logging frameworks, or even their own compilers. Make use of the technologies the cloud provides for heavy lifting related to authentication, moving data around, scaling, sending notifications and other tasks. When you leverage the capabilities in the cloud, you have more time to build the things that add value to your users.
Do you rock your role? Find out. Get your Microsoft Azure Developer Role IQ.