Tuesday, May 2, 2017

We were discussing an API for a scheduler that executed jobs. Services like that have the same notion at any level or scale. Therefore instead of being a microservice, it can also be considered as workflows. Take the example of Deis Workflow and we immediately see the benefit of expanding into a distributed service of any scale.
Before we review the Workflows, let us review the application needs. Applications are being built with a methodology that demands containerization.  This methodology involves twelve factors that allow applications to scale across distributed systems. The Twelve-Factor Apps is the distilled essence of hosting software as services on Heroku platform:
These are briefly enumerated below but more can be read on https://12factor.net
1.       Codebase – version control the software and deploy many times.
2.       Dependencies – Declare the dependencies and isolate them.
3.       Config – Configuration is part of the environment not the source.
4.       Backing services – All such services are satellite resources.
5.       Build, Release and Run – Build time and run time are separated
6.       Processes – The application is executed as stateless as possible. Think REST APIs
7.       Port Binding – Services are exported with the ports that they bind to
8.       Concurrency – The application is scaled out by forking more workers to the reentrant code
9.       Disposability – Applications are maximized for robustness with fast startup and graceful shutdown
10.   Dev/Prod parity – Each environment is similar to the other as much as possible. This improves maintenance
11.   Logging – All logging is treated as event stream
12.   Admin processes – Admin/management tasks are run as one-off processes.
Once the application is in this format, it can be hosted on distributed environment with Kubernetes containerization. Kubernetes is an open-source cluster manager that is developed by Google and donated to Cloud Native Compute Foundation Kubernetes provides automation to cluster activities  for the services such as state convergence, service addresses, health monitoring, service discovery and DNS resolution.
While Kubernetes provides abstractions like Services, Deployments and Pods, Workflows builds upon it.Workflow adds the features of building containers from application code, aggregating logs and managing deployment configurations and app releases. In fact, Deis workflow is all made up of Kubernetes components.
In terms of layers, Workflow therefore sits at the very top of the stack comprising of Workflow, Orchestration, Scheduling. Container Engine, Compute Operating System, Virtual Infrastructure and Physical Infrastructure as the seven layers.
#codingexercise
Here's an alternative way to count the occurrences of a given digit in sequential numbers upto a given number.
We can think of this as combinations with repetitions for r items among n which is equal to ((n+r-1) Choose r ) using stars and bars theorem and r ranges from 1 to n in this case. (r <= n )
So we sum the combinations with repetitions for each value of r for a given n
We repeat the above for
N ranging from single digit to as many digits in the given number.

Note that some of these generated numbers maybe larger than the given number. Therefore it is better to repeat the procedure above by fixing the first digit when the combination length is tge same as number length. 

No comments:

Post a Comment