What is Service Fabric: New runtime environment i.e. designed to allow highly scalable, highly reliable, highly manageable micro services to run on Azure and on premise (local clusters- Windows Server, Linux) environments. It is a developer platform for hyper scale, distributed applications.
Service Fabric represents the next-generation middleware platform for building and managing enterprise-class, Tier-1 cloud-scale applications.
Why is a microservices approach important? The two main reasons are:
- They enable you to scale different parts of your application depending on its needs.
- Development teams are able to be more agile in rolling out changes and thus provide features to your customers faster and more frequently.
Stateless and stateful Service Fabric microservices
Stateless microservices (protocol gateways, web proxies, etc.) do not maintain a mutable state outside of any given request and its response from the service. Azure Cloud Services worker roles are an example of a stateless service.
Stateful microservices (user accounts, databases, devices, shopping carts, queues, etc.) maintain a mutable, authoritative state beyond the request and its response.
By using Service Fabric, we can:
- Develop massively scalable applications that are self-healing.
- Develop applications composed of microservices using the Service Fabric programming model. Or, simply host guest executables and other application frameworks of your choice, such as ASP.NET Core 1, or Node.js.
- Develop highly reliable stateless and stateful microservices.
- Simplify the design of your application by using stateful microservices in place of caches and queues.
- Deploy to Azure or to on-premises clouds running Windows Server or Linux with zero code changes. Write once and then deploy anywhere to any Service Fabric cluster.
- Develop with a “datacenter on your machine” approach. The local development environment is the same code that runs in the Azure datacenters.
- Deploy applications in seconds.
- Deploy applications at higher density than virtual machines, deploying hundreds or thousands of applications per machine.
- Deploy different versions of the same application side by side, each independently upgradable.
- Manage the lifecycle of your stateful applications without any downtime, including breaking and nonbreaking upgrades.
- Manage applications using .NET APIs, PowerShell, or REST interfaces.
- Upgrade and patch microservices within applications independently.
- Monitor and diagnose the health of your applications and set policies for performing automatic repairs.
- Scale up or scale down your Service Fabric cluster easily, knowing that the applications scale according to available resources.
- Watch the self-healing resource balancer orchestrate the redistribution of applications across the cluster. Service Fabric recovers from failures and optimizes the distribution of load based on available resources.
Different way to write application in this programming model: Reliable Actors.
Actor Model: New model of building application, based on independent units, both state and code exist together and have messaging system to communicate between each other
Actor should be single threaded.
Monolithic Applications built in multiple layers, – Dealing with scalability of application is difficult in this case .Actor model provides finer granularity, elasticity scalability
Steps to build Reliable Actor applications- Reliable Actors Programming model
1. Define Actor Interface(s)
2. Implement Actor Interface(s)
3. Register the Actor implementation
4. Connect using Actor Proxy (used by both client and actor-actor communication)
Packaging and Deploying to Service Fabric Cluster
One Actor- can be one service or multiple actors in a service (multiple entities) and a service config, together packaged into a Service package.
Multiple Services like this can be packaged together in a Application Package- basically which is the logical unit for deployment to the Service Fabric cluster. Helps to manage- Lifetime (application activated, deactivated), Versioning, Isolation(security customized at application level)
The next post would be detailing how do we determine partitions and the process of allocating partitions accross the nodes based on the number of replicas.