Reader small image

You're reading from  Hands-On Azure for Developers

Product typeBook
Published inNov 2018
PublisherPackt
ISBN-139781789340624
Edition1st Edition
Tools
Right arrow
Author (1)
Kamil Mrzygłód
Kamil Mrzygłód
author image
Kamil Mrzygłód

Kamil Mrzygłód is a technical lead and technology advisor, working with multiple companies on designing and implementing Azure-based systems and platforms. He's a former Microsoft Azure Microsoft Most Valuable Professional (MVP) and certified trainer, who shares his knowledge via various channels, including conference speeches and open source projects and contributions. Kamil lives in Poland with his two cats and one dog, dedicating some of his time to video games, cooking, and traveling.
Read more about Kamil Mrzygłód

Right arrow

Distributed Applications and Microservices with Service Fabric

Service Fabric (SF) is a platform for distributed applications that greatly simplifies developing and deploying applications that are scalable and reliable. It's one of the best solutions for developing cloud-native apps and lets users focus on developing rather than on maintaining infrastructure and connections between particular components. It's a next-generation platform that is actively developed by Microsoft and has received much attention recently.

The following topics will be covered in this chapter:

  • Microservice architecture and how to use it in the cloud with SF
  • Basic concepts of SF, such as services or actors
  • Communicating between services in SF
  • Managing clusters in SF and securing them
  • Monitoring services in SF and how to diagnose them

Technical requirements

Understanding microservices

Probably you have heard about an architecture called microservices. There is no single definition that we could quote here, so the main purpose of this chapter will be to acquire a better insight into what we can call a microservice and how to develop an application in such a manner. This directly connects to SF, which is one of the biggest and most advanced services in Azure. If you aim at building a modular, loosely-coupled, and modern application, this particular cloud component is designed for you.

Monolith versus microservices

We will start our journey with microservices by comparing them with a traditional application, which is composed of multiple layers serving different purposes:

As you...

Containers, services, and actors in SF

To start with SF, we will cover three main topics, which allow you to divide an application logically and physically:

  • Containers: Small, deployable components that are isolated from each other and enable you to virtualize the underlying operating system
  • Reliable services: One of the programming models available in SD for writing and managing stateful and stateless services
  • Reliable actors: Another programming model on top of Reliable services

Containers

For now, SF supports two types of container:

  • Docker on Linux
  • Windows Server containers on Windows Server 2016

When working with containers in SF, you can use any programming language or framework (as you probably expected), but the...

Communication between services

You currently know how to work with SF using Reliable services and Reliable actors. The next important topic refers to communication between each instance of a service. As we discussed at the beginning of this chapter, the best option when building your microservices is to create a platform that will be agnostic when it comes to choosing what is the best way to communicate and accept incoming requests. In SF, you do not have a single way to exchange messages—instead you are provided with a complete framework to do it your way. In this section, we will focus on building a simple communication channel for your services.

Creating a communication channel

To create a channel, you will need...

Clusters in SF

We have talked about clusters in SF, but how can you really understand such a concept in that service? You probably remember that, during the creation of a cluster, we had to choose both node types and their characteristics—the number of VMs and their type. If you choose to have three nodes with five machines in each one, you will end up with a cluster of fifteen machines in total. SF automatically balances it, so if you are changing its size, all services will be redeployed to achieve maximum utilization. In this chapter, we will talk a little about security, available features, and scalability.

The following is a conceptual diagram of a cluster organization:

Cluster security

If you go back to the creation...

Monitoring and diagnostics

In the final section of this chapter, we will cover some topics regarding monitoring and diagnosing your services in SF. As you probably remember, I noted such features as one of the most important in microservices, as you have to always be able to tell how each one works and perform the needed action (such as scale out, restart, or kill an instance) if required. In SF, there are a few levels of monitoring that we will briefly describe here.

Application monitoring

In most cases, you want to monitor how your application works, what the user traffic is, and how your services communicate with each other. While you are able to bring your own framework, you can also leverage Application Insights (AI)...

Summary

In this chapter, we only took a brief look at SF and the microservices built with this Azure component. You have learned the basic concepts of SF, such as Reliable services and Reliable actors, and how to implement a communication protocol to exchange messages between services and clients. Remember that building an application based on microservices is not a trivial task and requires sticking to many important rules to avoid problems with dealing with state, monitoring, or scaling. Use SF as a framework for building distributed applications, which takes care of ensuring that they are reliable and highly available.

Last but not least: do not be discouraged if you have problems with SF or feel overwhelmed by its multiple options and configurations—this particular service has a pretty difficult learning curve, but after reading this whole chapter, you should be able...

Questions

  1. What is the difference between Reliable services and Reliable actors?
  2. What is the difference between stateless and stateful services?
  3. What one has to be implemented to introduce its very own communication channel in SF?
  4. What is node type in SF?
  5. Can you scale (up/out) node types individually?
  6. Can you select a VM SKU when creating a cluster?
  7. What are the two types of node security in SF?
  8. What is the difference between cluster, application, service, partition, and replica?
  9. Why does SF advocate creating a node with at least five VMs?
  10. What is the reliability tier in SF?
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Azure for Developers
Published in: Nov 2018Publisher: PacktISBN-13: 9781789340624
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Kamil Mrzygłód

Kamil Mrzygłód is a technical lead and technology advisor, working with multiple companies on designing and implementing Azure-based systems and platforms. He's a former Microsoft Azure Microsoft Most Valuable Professional (MVP) and certified trainer, who shares his knowledge via various channels, including conference speeches and open source projects and contributions. Kamil lives in Poland with his two cats and one dog, dedicating some of his time to video games, cooking, and traveling.
Read more about Kamil Mrzygłód