Wednesday, 29 November 2023

Measuring System Reliability: A Comprehensive Guide

 

Reliability means how well something, like a system or a service, does its job and keeps doing it right. If something is reliable, you can trust it to work the way it's supposed to, even when things are complex.

 

Different ways to measure Reliability

1. Mean Time Between Failures (MTBF)

MTBF is a measure that figures out how much time, on an average, passes between one problem and the next problem in a fixable system. If the MTBF is higher, it means the system is more trustworthy because it can go for a longer time without having issues.

 

Formula

MTBF = Total Time the System Works / Number of Times it Breaks

 

For example, let's say there's a service running for a total of 10 hours, and during that time, it stops working 5 times. To find the MTBF for this service:

 

MTBF = 10 hours / 5 failures = 2 hours

 

2. Mean Time To Repair (MTTR)

Mean Time To Repair (MTTR) is an important thing to look at when dealing with microservices. It tells us, on an average, how much time it takes to fix a microservice that's not working properly.

 

Formula

MTTR = Total Time Spent Fixing / Number of Times Something Went Wrong

 

Where,

a.   Total Time Spent Fixing: It is the total amount of time spent fixing all the problems that happened during the time we were watching.

b.   Number of Failures: This is how many times the microservice didn't work as expected.

 

For instance, if total time spent to repair is 10 hours and total failures are 5, then

 

MTTR = 10 hours / 5 failures = 2 hours

 

So, on average, it takes 2 hours to fix a microservice when it's not working right.

 

3. Availability

Availability is a measure of how often a system or component is operational and accessible to users. We usually talk about it as a percentage, where higher percentages mean the system is available more.

 

For instance, if a system has 99.5% availability means that it is supposed to be working 99.5% of the time, and there's only 0.5% of the time when it's not working.

 

Formula

Availability = (Total Uptime / Total Time) * 100%

 

where:

 

a.   Total Uptime is the total amount of time the system or component was operational.

b.   Total Time including uptime and downtime.

 

For example, if the total time is 1000 hours and total up time is 999 hours, then

Availability = (999 / 1000) * 100 = 99.9 percentage

 

4. Failure Rate

Failure rate is the number of failures that occur in a system or component per unit of timesuch as failures per hour. A higher failure rate means there's a higher chance of things not working.

 

Formula

Failure Rate = (Number of Failures / Total Exposure Time)

 

where:

For example, if a system has 10 failures in 100 hours, then the failure rate is:

 

Failure Rate = (10 / 100 hours) = 0.1 failures/hour

 

5. Reliability Block Diagrams (RBD)

Think of a big system with lots of connected parts like microservices. Each little part has its own reliability. RBD used to model the flow of success or failure through a system and to calculate the overall reliability of the system as a whole.

 

How RBD Works?

An RBD is drawn as a series of connected blocks , where each block represent components or subsystems of the system. The blocks are connected in a series or parallel configuration. A series connection indicates that all blocks must be in the success state for the system to be in the success state. A parallel connection indicates that only one block needs to be in the success state for the system to be in the success state.

 

Series Configuration

If they're in a line, it means the system only works if all the parts in a row work. The overall reliability (R_sys) is how good each part is, multiplied together.

 

Example

Think about a payment system with three parts (Authentication and Authorization Service, Payment Service, Database) in a series.

 


Authentication and Authorization Service reliability R1 =  0.98

Payment service reliability R2 =  0.94

Database reliability R3 = 0.99

Total reliability of the system = R1 * R2 * R3 = 0.9119

So, the system reliability in this serial configuration is 0.855 or 91.19%.

 

Parallel configuration

In a parallel configuration, the system is operational if at least one of the components is operational. The overall reliability (R_sys) is the complement of the probability that all components fail simultaneously.

 


 

If the reliability of service 1 is R1 = 0.99

​If the reliability of service 2 is R2 = 0.95

the overall system reliability (R_sys) is given by:

R_sys = 1 - (1-R1) * (1 - R2)

      = 1−(1−0.99)×(1−0.95)

      = 1 - (0.01 * 0.05)

      = 1 - 0.005

      = 0.9995

 

So reliability of the system is 99.95%

 

6. Service level Agreements (SLAs)

SLA is a contract between a service provider and a customer that defines the level of service that the service provider will provide to the customer. SLAs can be used as a reliability metric to some extent. They provide a framework for defining and measuring the performance of a service, which can be used to assess its reliability.



                                                             System Design Questions

Tuesday, 28 November 2023

Quick Introduction to Deployment diagram in PlantUML

 

Deployment diagram model the physical architecture of the system.

 

PlantUML support following elements to work with deployment diagram.

 

·      actor

·      agent

·      artifact

·      boundary

·      card

·      circle

·      cloud

·      collections

·      component

·      control

·      database

·      entity

·      file

·      folder

·      frame

·      hexagon

·      interface

·      label

·      node

·      package

·      queue

·      rectangle

·      stack

·      storage

·      usecase

 

helloworld.txt

@startuml

title "Deployment diagram elements"

actor actor1
agent agent1
artifact artifact1
boundary boundary1
card card1
circle circle1
cloud cloud1
collections collections1
component component1
control control1
database database1
entity entity1
file file1
folder folder1
frame frame1
hexagon hexagon1
interface interface1
label label1
node node1
package package1
queue queue1
rectangle rectangle1
stack stack1
storage storage1
usecase usecase1

@enduml

 

Above snippet generate below diagram.

 


 

 

Previous                                                    Next                                                    Home

Hide or remove unlinked components in PlantUML

PlantUML display all the components by default. You can hide or remove unlinked components using hide or remove commands.

 

Syntax

hide @unlinked
remove @unlinked

 

defaultBehvior.txt

@startuml

component C1
component C2
component C3
component C4
component C5

[C1] --> [C2]
[C1] --> [C5]

@enduml

Above snippet generate below diagram.


 


 

Hide unlinked components

hideUnlinkedComponents.txt

@startuml

hide @unlinked

component C1
component C2
component C3
component C4
component C5

[C1] --> [C2]
[C1] --> [C5]

@enduml

Above snippet generate below diagram.




Remove unliked components

 

removeUnlinkedComponents.txt

@startuml

remove @unlinked

component C1
component C2
component C3
component C4
component C5

[C1] --> [C2]
[C1] --> [C5]

@enduml

 

Above snippet generate below diagram.


 

  

 

Previous                                                    Next                                                    Home

Customize color, fonts of component diagram using skinparam command in PlantUML

‘skinparam’ command is used to customize the font and colors of components.

componentColors.txt

@startuml

skinparam BackgroundColor transparent

skinparam package {
	backgroundColor gold 
}

skinparam node {
	borderColor Green
	backgroundColor Yellow 
}

skinparam component {
	backgroundColor<<automated>> DarkKhaki
	backgroundColor<<tested>> Green
	backgroundColor PaleGreen
}

skinparam database{
	BackgroundColor Aqua
}

skinparam cloud {
	BackgroundColor #00FF05
}

skinparam folder {
	backgroundColor lightblue 
}

skinparam frame {
	backgroundColor lightyellow 
}

package "Package1"{
	HTTPS --> [Component1]
	[Component2]
}

node "node1" {
	[Component3] <<automated>> as Component3
	SFTP --> [Component3]
	[Component4]
}

cloud "cloud1"{
	[Component5] <<tested>> as Component5
	WEBServices --> [Component5]
	[Component6]
}

database "databaseServers" {
	[MySQL]
	[MongoDB]
}

folder "userInfoFolder"{
	[AdminDetails]
	[UserDetails]
	[SupportUserDetails]
}

frame "frame1"{
  [Component10]
  [Component11]
}

[Component1] --> [Component5]
[Component6] --> [MySQL]
[Component11] --> [MongoDB]
[Component3] --> [Component10]

@enduml

 

Above snippet generate below diagram.

 


 

Previous                                                    Next                                                    Home

Add colors to the component in PlantUML

Using #color notation, we can add colors to the component.

Example

component "Balance Enquiry" as BE #Yellow
[Cash Withdrawl] as CE #PaleGreen

componentColors.txt

@startuml

[User]

package "ATM Machine" {
	component "Balance Enquiry" as BE #Yellow
	[Cash Withdrawl] as CE #PaleGreen
	component [Amount Deposit] #Aqua
	[Request Loan] #Gold
	[Transfer Amount] #Silver
}

package "Bank Server"{
	cloud {
		[Account Manager] #red
	}
}

package "Loan Server"{
	cloud {
		[Loan management system] #LightBlue
	}
}

[User] --> [BE]
[User] --> [CE]
[User] --> [Amount Deposit]
[User] --> [Request Loan]
[User] --> [Transfer Amount]

[BE] --> [Account Manager]
[CE] --> [Account Manager]
[Amount Deposit] --> [Account Manager]
[Transfer Amount] --> [Account Manager]

[Request Loan] --> [Loan management system]

[Loan management system] --> [Account Manager]

@enduml

Above snippet generate below diagram.


 

Previous                                                    Next                                                    Home

Monday, 27 November 2023

Concatenates the byte arrays in Java

Following snippet concatenates the byte arrays in Java.

public static byte[] concat(byte[]... byteArrays) {

	try {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();

		for (byte[] byteArray : byteArrays) {

			if (byteArray == null) {
				continue;
			}

			baos.write(byteArray);
		}
		return baos.toByteArray();

	} catch (IOException e) {
		throw new IllegalStateException(e.getMessage(), e);
	}
}

Above snippet defines a method ‘concat’ that combines multiple byte arrays into a single byte array. It uses a ByteArrayOutputStream to store the concatenated byte arrays. The method checks for null byte arrays and skips them. For non-null byte arrays, it writes their content to the ByteArrayOutputStream. After processing all input byte arrays, the content of the ByteArrayOutputStream is converted into a single byte array, which is then returned.

 

Find the below working application.

 

ByteArrayConcatenation.java

package com.sample.app;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class ByteArrayConcatenation {

	public static byte[] concat(byte[]... byteArrays) {

		try {
			ByteArrayOutputStream baos = new ByteArrayOutputStream();

			for (byte[] byteArray : byteArrays) {

				if (byteArray == null) {
					continue;
				}

				baos.write(byteArray);
			}
			return baos.toByteArray();

		} catch (IOException e) {
			throw new IllegalStateException(e.getMessage(), e);
		}
	}

	public static void main(String[] args) {
		byte[] arr1 = { 2, 3, 5, 7 };
		byte[] arr2 = { 23, 25, 27, 29 };
		byte[] arr3 = { 33, 35, 37, 39 };

		byte[] concatenatedArray = concat(arr1, arr2, arr3);
		
		System.out.println("Elements in the concatenated array are : ");
		for(byte b : concatenatedArray) {
			System.out.println(b);
		}

	}

}

Output

Elements in the concatenated array are : 
2
3
5
7
23
25
27
29
33
35
37
39




You may like

Interview Questions

Array programs in Java

Get the string representation of array by given delimiter in Java

Get an iterator from array in Java

Get reverse iterator for the given array in Java

Convert primitive array to wrapper array in Java

Convert a wrapper array to primitive array in Java