Skip to main content

Should we trust a services for our communication channel or should we use our own channel and protocol?

Nowadays there are a lot of mechanism that can be used to connect devices from the field to our own system and infrastructure. If we are looking at the services that are offered by cloud providers, we will discover that each cloud provider one or more solution that can be used at a messaging or transport platform between our devices and backed.
For example, if we take Microsoft Azure, we have Storage Queues and Service Bus ‘Suite’ (that contains Topics, Queues, Relay and Event Hub). Looking at an offered like this, we ask our self what service should be used. In the end, all this services are extraordinary and can bring value to our solution.

In this post we will debate about a simple question that I heard a lot of times in the last 2 years in different meetings and/or project:
Should we trust a services for our communication channel or should we use our own channel and protocol? 

Before jumping into the discussion let’s elaborate the question a little more. The communication between two different endpoint (device and backed) can be done over HTTP(s) or TCP. This can be done by defining our own protocol and contracts OR we can rely on an external provider that would offer all the infrastructure that we need.

In the seccond case, we have control to the content that is send over the wire, but a part of the contract is defined by the external provider that created the communication channel.
Let’s take for example a messaging system like Azure Service Bus Topic. Microsoft Azure provides us a REST API that can be used to send messages over the wire. Amazon SNSis another services provided by AWS that offers us something similar.
All this services are great, work as expected, but what is happening if we create a system that will be develop in 2 or 3 years, will be in a testing phase for 1 year and will need to run for 10 years… We need to be able to provide a robust solution that can run for ~14 years without having to change it too much.
Why we need something like this. Because is pretty hard and complex to change/modify the communication channel. In a regulatory field like banking or life science this will required a lot of time and effort. On top of this, all the time we will have some machines or devices where the update was not installed successfully and we need human intervention – extra costs.

In this moment there is no cloud providers that will guaranty to you that the current service API will not be change (or braking change) in the next 2 or 5 years. In 5 years for example they could be at v8 and v1 will not be supported anymore. Or the authentication mechanism that is used will be outdated and will be discontinue.
This is a risk that appears when we need SaaS (Software as a Services). In this cases we don’t have any kind of control to the service that we consume. For example Microsoft will announce us with at least year before a breaking change will be made to the API.
The good part about this is that almost all cloud providers in this moment are backward compatibility. All of them are supporting the old version of their APIs even if are deprecated or without the last features that were added in the last period of time.
On the other hand, working with a REST API or system hosted by us will give us the full control of what kind of API we expose, what is the contract and so on. Even if we are hosting the machines that exposes the API in cloud, we fully manage the API and control this. In this way we can support the old API as long as needed.
A solution like this will come automatically with extra costs – development, maintenance and support.

A decision between this two solutions is pretty hard to take and is not simple. We need to take into account what kind of clients will access our endpoints, what is the costs of a custom solution and for how our solution will be used. Of course we need to think about how easy a change can be pushed into the system.
In the last months, we had to take a decision like this. We took into consideration the fallowing parameters:

  • For how long the solution should run without major changes: long time (8-10 years)
  • How easy a major change can be pushed into the system: very hard
  • In a case of an update fail how critical is to be able to reconnect to the device: high
  • How expensive is an API change: high
  • Are we working in a regulatory field: yes
  • Is there a high risk after an update to lose the connection with the devices: yes


Based on this risks and the information that we have in this moment we decided to expose our own API and manage all the communication by ourselves. We decided to expose a REST API to the public endpoint. Of course behind this API we have the messaging systems that handles all the communication. The REST API is like a wrapper over the messaging system as SaaS. In this way we can fully manage and control the contracts between backend and devices. It is more simple to update a components that is deployed on 10 or 100 servers in comparison with a client application that is deployed on 500.000 devices.

Comments

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(

Azure AD and AWS Cognito side-by-side

In the last few weeks, I was involved in multiple opportunities on Microsoft Azure and Amazon, where we had to analyse AWS Cognito, Azure AD and other solutions that are available on the market. I decided to consolidate in one post all features and differences that I identified for both of them that we should need to take into account. Take into account that Azure AD is an identity and access management services well integrated with Microsoft stack. In comparison, AWS Cognito is just a user sign-up, sign-in and access control and nothing more. The focus is not on the main features, is more on small things that can make a difference when you want to decide where we want to store and manage our users.  This information might be useful in the future when we need to decide where we want to keep and manage our users.  Feature Azure AD (B2C, B2C) AWS Cognito Access token lifetime Default 1h – the value is configurable 1h – cannot be modified

What to do when you hit the throughput limits of Azure Storage (Blobs)

In this post we will talk about how we can detect when we hit a throughput limit of Azure Storage and what we can do in that moment. Context If we take a look on Scalability Targets of Azure Storage ( https://azure.microsoft.com/en-us/documentation/articles/storage-scalability-targets/ ) we will observe that the limits are prety high. But, based on our business logic we can end up at this limits. If you create a system that is hitted by a high number of device, you can hit easily the total number of requests rate that can be done on a Storage Account. This limits on Azure is 20.000 IOPS (entities or messages per second) where (and this is very important) the size of the request is 1KB. Normally, if you make a load tests where 20.000 clients will hit different blobs storages from the same Azure Storage Account, this limits can be reached. How we can detect this problem? From client, we can detect that this limits was reached based on the HTTP error code that is returned by HTTP