Skip to main content

Posts

Benchmark Key Value Swapping of a Dictionary in Python

Today, I was writing a python script and needed to swap the keys and values in a dictionary. While doing it, I wanted to see how long it takes to perform such a swap operation on small dictionaries. To determine which solution is the fastest on CPU, we can use the  timeit  module in Python to benchmark each solution. The methods I will be testing is that A similar way to list comprehension using  zip() Iterating the dictionary keys with for loop Here’s an example benchmark: import timeit existing_dict = { "a" : 1 , "b" : 2 , "c" : 3 } def solution1 (): return {v: k for k, v in existing_dict . items()} def solution2 (): return dict(zip(existing_dict . values(), existing_dict . keys())) def solution3 (): swapped_dict = {} for k, v in existing_dict . items(): swapped_dict[v] = k return swapped_dict print( "Solution 1:" , timeit . timeit(solution1, number = 100000 )) print( "Solution 2:" , time...

Advanced Raid Failure Simulations Using Mdadm

Introduction RAID (Redundant Array of Independent Disks) provides fault tolerance and performance benefits, but even the best setups can experience failures. Understanding how RAID handles disk failures and how to recover from them is crucial for system administrators. In this guide, we will simulate RAID failures using  mdadm , analyze failure scenarios, and practice recovery techniques for RAID 0, 1, 5, and 10. Preparing a RAID Environment Before simulating failures, ensure you have a working RAID setup. If you don’t already have a RAID array, create one using the guide from our previous article. Simulating Failures in RAID RAID 0 (Striping) – Single Disk Failure RAID 0 offers performance benefits but no redundancy. A single disk failure leads to total data loss. Failure Simulation: sudo mdadm --fail /dev/md0 /dev/sdb Check RAID Status: cat /proc/mdstat sudo mdadm --detail /dev/md0 Expected Outcome: The entire RAID array fails, making data recovery impossible. If thi...

Troubleshooting Your RAID: A Quick Guide

Introduction RAID (Redundant Array of Independent Disks) is designed to improve storage reliability, performance, and redundancy. However, disk failures, data corruption, and array degradation can still occur. This guide provides an introductory approach to diagnosing and resolving RAID disk issues effectively. Common RAID Issues and Symptoms 1. Degraded RAID Array If your RAID is operational but running in degraded mode due to a failed disk, then you can check the following cat /proc/mdstat sudo mdadm --detail /dev/md0 Here you can identify the failed disk and replace it with a new one. 2. Failed RAID Rebuild If the RAID rebuild fails to complete, or the array remains degraded, then you can check the mdraid details sudo mdadm --detail /dev/md0 Go for the logs to check something is logged related to mdraid or disk failure. You can also consult to  dmesg  command. sudo dmesg | grep md Verify disk health using SMART diagnostics and retry the rebuild. 3. RAID Not Detecting a New...

Setting Up Raid on Linux Using Mdadm

Introduction Redundant Array of Independent Disks (RAID) is a technology that enhances storage performance, redundancy, or both. While hardware RAID has been around for decades, Linux users commonly employ  mdadm (Multiple Device Admin)  to create and manage software RAID arrays. In this guide, we will explore RAID’s history, its early challenges, and how to set up various RAID levels (RAID 0, 1, 5, 10) using  mdadm  in Linux. A Brief History of RAID RAID was first conceptualized in  1987  by  David A. Patterson, Garth A. Gibson, and Randy H. Katz  at UC Berkeley. Their paper, “A Case for Redundant Arrays of Inexpensive Disks,” introduced multiple RAID levels, each balancing speed, fault tolerance, and cost-effectiveness. Before RAID became mainstream, storage solutions relied on  single large expensive disks (SLEDs) . Failures meant complete data loss, and expanding storage was cumbersome. RAID allowed combining smaller, cheaper disks into m...

Getting Started With Ceph

Ceph Introduction Ceph  has evolved a lot after its birth at 2007, habing important milestones like  RedHat  and later on becomes  IBM  after they acquired RedHat. The users and administrators may have know a lot about it, but these milestones probably take the software a lot further that it was thought to be. After the IBM era, Ceph is aimed to have one major relase per year, keep the last 2 supported and expire the rest. One of the biggest advantages of Ceph is that it is horizontally scalable or in brief it has a scale out architecture. There are also several softwares serving storage under different orientation, such as  MinIO ,  GlusterFS ,  Open ZFS ,  DRDB ,  Lustre  etc. They all have pros and cons against each other. Of course this list can be extended including the proprietary softwares and appliances, but here we are mostly touching to opensource softwares. Since Ceph has a wide storage offerings, it can be used in many d...

How to Prepare a Blog Using Hugo

Introduction As some of you may notice, I have been playing with some blogging softwares for the last 2 years. Like most of the people I have started blogging with Google’s Blogger and switches to Wordpress. They were all nice, however I was looking for something more straightforward and have more control. Knowing that I am not a web developer, most of the sections in Wordpress and others were totally out of my understanding. By the way, I also remembered that I tried Wix. If you would like to stick with their templates and methods, Wordpress, Wix, GoDaddy etc, are all good products. Here, as an engineer, I was looking something more, and discover the world of self hosting, and started checking different categories of it, then I found myself in Static Site Generators which I have never heard before. There were many opensource softwares listed, and they have huge amounts of stars in Github and noticed that it is widely used. First, I tried to understand the logic of the Static Site Gene...