Normal view

There are new articles available, click to refresh the page.
Yesterday — 17 October 2024python

Ubuntu : சும்மா இருந்ததால் வந்த சிக்கல்

By: Hariharan
17 October 2024 at 18:48

அக், 17 2024

இரவு ஒரு 10: 35 மணி இருக்கும் கணினியை திறந்து லாகின் செய்து விட்டு குரோமியம் உலவியில் தமிழ் லினக்ஸ் பாரத்தில் போட்ட கேள்விக்கு பதில் வந்ததா என்று பார்த்துக்கொண்டிருந்தேன்.

பார்த்துகொண்டிருக்கும் போது ஜேசன் அவர்களின் பதிவு தந்தி(Telegram App)யில் வந்தது. அதில் A2D நந்தா அவர்களின் CDK Offers மற்றும் CDKLabs பற்றிய சில செய்திகள் வந்தது. அவற்றையெல்லம் பார்த்துவிட்டு கணினியில் சுட்டியை சொடுக்கினேன் செய்தேன். எதற்கும் ஒத்துழைக்க வில்லை ஆனால் சுட்டி மட்டும் நகர்ந்தது. விசைப்பலகையை தட்டி டெர்மினலில் எதேனும் கட்டளைகளை பயன்படுத்தி குரோமியத்தினை நிறுத்திவிட்டு மீள் தொடங்கலாம் என நினைத்தேன். ஆனால் விசைகள் இயங்கின அதனுடைய உள்ளீட்டை கணிணி ஏற்கவில்லை.

திறன்பேசியில் தேடினேன்.

ரெடிட்டில் ஒரு பதிவு கிடைத்தது. அதில் குறிப்பிட்ட படி ctrl+alt+F3 யை அழுத்தினேன். பின்னர்

sudo systemctl status gdm 

கட்டளையிட்டேன் (inactive) நிலையில் இருந்தது. பின்னர் நான் lightdm பயன்படுத்துவதால் அதனுய நிலையை சரிபார்த்தேன்.

sudo systemctl status lightdm

அது இயக்கத்தில் இருந்தது. lightdm ஐ மீள்தொடக்கம் செய்தேன். பின்வரும் கட்டளை கொண்டு

sudo systemctl restart lightdm

மீள் தொடக்கம் செய்ததும் விசைப்பலகை சரியாக இயங்கியது. சுட்டியும் நன்றாக இயங்கியது.

நன்றாக இயங்கியதால் இந்த பதிவையும் எழுத முடிந்தது.

நன்றி.

https://www.redit.com/r/Ubuntu/comments/133js51/unable_to_click_in_but_mouse_moves_ubuntu/

ரெடிட் பதிவு

Before yesterdaypython

Kanchilug Monthly Meet – Oct ,13 2024

By: Hariharan
13 October 2024 at 16:30

Lightning Talk by Krishna

Topic : Desktop Customization : picom, pywal

Resource : Krishna S

SSD File System Comparison : https://www.linux.org/threads/comparison-of-file-systems-for-an-ssd.28780/

https://etherpad.wikimedia.org/p/KanchiLUGMMOct13

Notes on Choosing HDD to SSD Linux Installation migration

Chat GPT Prompt : how to backup current linux installation configuration files and packages list as a archive and apply on a new installation

Result

Backing up your current Linux installation’s configuration files and package lists is a great way to ensure you can easily restore or replicate your setup on a new installation. Here’s how you can do it:

Step 1: Backup Configuration Files

  1. Identify Configuration Files: Most configuration files are located in /etc. You may also have application-specific configurations in your home directory (like .bashrc, .vimrc, etc.).
  2. Create an Archive:
    You can create a compressed archive (like a tarball) of your configuration files. Run the following command:
   sudo tar -czvf config_backup.tar.gz /etc /home/your_username/.bashrc /home/your_username/.vimrc

Adjust the paths based on what configuration files you want to back up.

Step 2: Backup Installed Packages List

The method to back up the installed package list depends on your Linux distribution.

For Debian-based systems (like Ubuntu):

  1. Backup Installed Packages:
   dpkg --get-selections > package_list.txt
  1. Backup Sources List:
   sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

For Red Hat-based systems (like Fedora, CentOS):

  1. Backup Installed Packages:
   rpm -qa > package_list.txt
  1. Backup Repositories:
   sudo cp -r /etc/yum.repos.d/ /path/to/backup/repo_backup/

Step 3: Create a Complete Backup Archive

Combine everything into one archive:

tar -czvf full_backup.tar.gz config_backup.tar.gz package_list.txt /etc/apt/sources.list.backup

Step 4: Restore on a New Installation

  1. Transfer the Backup: Copy the full_backup.tar.gz to your new installation.
  2. Extract the Backup:
   tar -xzvf full_backup.tar.gz
  1. Restore Configuration Files:
   sudo tar -xzvf config_backup.tar.gz -C /
  1. Restore Package List: For Debian-based systems:
   sudo dpkg --set-selections < package_list.txt
   sudo apt-get dselect-upgrade

#### For Red Hat-based systems:
You can reinstall packages from the list:

   xargs -a package_list.txt sudo dnf install -y
  1. Restore Sources List (Debian-based):
   sudo cp /etc/apt/sources.list.backup /etc/apt/sources.list
   sudo apt update

Step 5: Finalize and Reboot

After restoring everything, it’s a good idea to reboot your system to ensure all configurations take effect.

Notes:

  • Make sure to review any new configurations or installed packages after the restoration, as dependencies and versions may vary.
  • For user-specific configurations, you may want to back up the entire home directory or specific application directories.

This process should help you smoothly transition to a new Linux installation with your desired configurations and packages!

Chat GPT Prompt : I am in a plan of migrating linux os to a new file system which is xfs or zfs brtfs which on is good

Choosing between XFS, ZFS, and Btrfs depends on your specific needs and use cases. Here’s a breakdown of each file system’s strengths and considerations to help you decide:

XFS

Pros:

  • Performance: Excellent performance, especially for large files and high-performance workloads.
  • Scalability: Designed for scalability, making it suitable for high-capacity storage systems.
  • Mature: A well-established file system with a long history of stability.

Cons:

  • Features: Lacks some advanced features like snapshots and built-in RAID compared to ZFS and Btrfs.
  • Management: Does not have as many management tools as ZFS.

ZFS

Pros:

  • Data Integrity: Strong focus on data integrity with built-in checksumming.
  • Snapshots and Clones: Supports efficient snapshots and clones, allowing for easy backups and recovery.
  • Compression: Offers built-in compression options, which can save space.
  • RAID: Supports various RAID levels natively (ZRAID), enhancing redundancy.

Cons:

  • Memory Usage: Can require more RAM for optimal performance.
  • Complexity: More complex to set up and manage compared to traditional file systems.

Btrfs

Pros:

  • Snapshots and Subvolumes: Supports snapshots and subvolumes, making it flexible for backups and system management.
  • Built-in RAID: Offers support for multiple RAID levels.
  • Compression and Deduplication: Supports on-the-fly compression and deduplication.

Cons:

  • Stability: Still considered less mature than XFS and ZFS; while it has improved significantly, it may not be as stable for all workloads.
  • Performance: Can have variable performance depending on the workload and configuration.

Recommendations

  • For General Use: If you want stability and performance for general workloads, XFS is a great choice.
  • For Data Integrity and Advanced Features: If data integrity, snapshots, and advanced features are critical, ZFS is likely the best option.
  • For Flexibility and Modern Features: If you want modern features like snapshots and subvolumes with some flexibility, consider Btrfs.

Final Thoughts

Evaluate your specific use cases (e.g., data integrity, performance, ease of management) and the resources available on your system (e.g., RAM for ZFS). If possible, testing each file system in a non-production environment can also help you determine which one best meets your needs.

Top Data quality tools

9 October 2024 at 05:03

Image descriptionTop 10 Data Quality Tools

⎯⎯⎯⎯⎯⎯⎯⎯⎯  
⎯⎯⎯Source From @ Deepak Bhardwaj ⎯⎯⎯⎯⎯

➤ 𝐀𝐛 𝐈𝐧𝐢𝐭𝐢𝐨
↳ Comprehensive data management with advanced data quality features.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Automated data analysis, rule definition, issue ticketing, centralised control.

➤ 𝐒𝐀𝐒 𝐃𝐚𝐭𝐚 𝐐𝐮𝐚𝐥𝐢𝐭𝐲
↳ Enhances data accuracy, consistency, and completeness with comprehensive tools.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Data profiling, duplicate merging, standardisation, SAS Quality Knowledge Base.

➤ 𝐃𝐐𝐋𝐚𝐛𝐬 𝐏𝐥𝐚𝐭𝐟𝐨𝐫𝐦
↳ Holistic data quality and observability tool using AI and machine learning.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Automated data profiling, anomaly detection, proactive monitoring.

➤ 𝐎𝐩𝐞𝐧𝐑𝐞𝐟𝐢𝐧𝐞
↳ A free, open-source tool for cleaning and transforming messy data.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Data consistency, error correction, versatile data transformations.

➤ 𝐏𝐫𝐞𝐜𝐢𝐬𝐞𝐥𝐲 𝐃𝐚𝐭𝐚 𝐈𝐧𝐭𝐞𝐠𝐫𝐢𝐭𝐲 𝐒𝐮𝐢𝐭𝐞
↳ A modular suite provides data quality, governance, and mastering.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Profiling, cleansing, standardisation, real-time data visualisation.

➤ 𝐎𝐫𝐚𝐜𝐥𝐞 𝐄𝐧𝐭𝐞𝐫𝐩𝐫𝐢𝐬𝐞 𝐃𝐚𝐭𝐚 𝐐𝐮𝐚𝐥𝐢𝐭𝐲
↳ Comprehensive solution for data governance and quality management.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Data profiling, extensible features, batch and real-time processing.

➤ 𝐓𝐚𝐥𝐞𝐧𝐝 𝐃𝐚𝐭𝐚 𝐅𝐚𝐛𝐫𝐢𝐜
↳ Unified platform for data integration and quality management.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Data profiling, cleansing, integration, real-time monitoring.

➤ 𝐒𝐀𝐏 𝐃𝐚𝐭𝐚 𝐒𝐞𝐫𝐯𝐢𝐜𝐞𝐬
↳ Advanced tool for data integration and quality across diverse sources.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Data transformation, cleansing, profiling, integration with SAP systems.

➤ 𝐀𝐭𝐚𝐜𝐜𝐚𝐦𝐚 𝐎𝐍𝐄
↳ An AI-powered platform integrating data governance, quality, and master data management.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Data profiling, real-time monitoring, integrated data catalog.

➤ 𝐈𝐧𝐟𝐨𝐫𝐦𝐚𝐭𝐢𝐜𝐚 𝐂𝐥𝐨𝐮𝐝 𝐃𝐚𝐭𝐚 𝐐𝐮𝐚𝐥𝐢𝐭𝐲
↳ AI-driven data quality solution for cloud and hybrid environments.
↳ 𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬: Data profiling, cleansing, automated anomaly detection, CLAIRE engine.

Cheers!
Deepak Bhardwaj

Keyboard Tamil99 :தேடிய விசைப்பலகை பயிற்சி வலைதளம் கிடைத்தது.

By: Hariharan
5 October 2024 at 18:09

அக் 5, 2024

தமிழில் தட்டச்சு செய்ய தமிழ்99 விசைப்பலகை பயன்படுத்த மிகவும் எளிதாக இருக்கும். முதலில் இருந்தே எகலப்பை மற்றும் தமிழ் பொனெட்டிக்(ஒலிப்பு) விசைப்பலகையில் தமிழில் தட்டச்சு செய்ய பழகிய என்னை போன்றவர்களுக்கு தமிழ் தட்டச்சு செய்ய தமிழ்99 விசைப்பலகை பயிற்சி எடுக்க மிகவும் கடினமாக இருக்கிறது.

ஆகவே இந்த சிக்கலை தீர்க்க எதேனும் வலைதளங்கள் இருக்கின்றனவா என தேடிய பொழுது கிடைத்த ஒர் வலைதளம்.

https://wk.w3tamil.com/

இந்த வலைதளத்தில் தமிழ்99 விசைப்பலகையை பயிற்சி பெற 3 வித அமைப்புகள் உள்ளன.

முதல் அமைப்பு தமிழ்99 விசைப்பலகை மட்டும் வைத்துகொள்வது. இதில் வடமொழி மற்றும் ஆங்கில எழுத்துகள் இருக்காது.

இரண்டாம் அமைப்பு தமிழ்99 விசைப்பலகை வடமொழி எழுத்துகள் உடன் ஆங்கில எழுத்துகளும் லேசான நிறத்தில் தோன்றும் வடமொழி எழுத்துகளை தட்டச்சு செய்ய {shift} விசையை பயன்படுத்தவும்.

மூன்றாம் அமைப்பு தமிழ்99 விசைப்பலகை வடமொழி எழுத்துகள் உடன் ஆங்கில எழுத்துகளும் அடர் நிறத்தில் தோன்றும் .

தொடக்க பயனர்கள் மூன்றாம் அமைப்பை பயன்படுத்தலாம் எளிமையாக ஆங்கில எழுத்துக்களின் விசையை பயன்படுத்தி பழகலாம் பின்னர் நன்கு பயிற்சி பெற்றபின் முதலாம் அமைப்பிற்கு வரலாம்.

வாங்க பழகலாம் தமிழ்99!

How to Deploy a Laravel application in Shared Hosting

By: Hariharan
5 October 2024 at 16:25

Preparing Hosting Infrastructure for Deployment:

  1. Create a subdomain or main domain
  2. login into public_html folder of the site or subdomain
  3. put a index.html file and check if the sub domain is working

Laravel Project Upload :

  1. Prepare a Zip Archive of the Laravel Project
  2. Create a folder into server and extract your project into public_html folder created earlier
  3. Then change the public folder content to the public_html folder and change the bootstrap and other paths in index as per need
  4. After that you’re going to check

Ubuntu : How to make partitions mount at startup -தமிழில்

By: Hariharan
1 October 2024 at 17:42

அக் 01, 2024

உபுண்டு இயக்கமுறையில் வன்வட்டு மற்றும் திடநிலைவட்டினை இயங்குதளத்தின் தொடக்கத்தில் இணைப்பது எவ்வாறு என்பதனை இக்கட்டுரையில் காண்போம்.

பயனர் இடைமுக வழி (புதிய பயனர்களுக்கு) : வட்டுகள் (Disks) எனும் பயன்பாடானது தானமைவாகவே

/etc/fstab

கோப்பினை நமக்காக திருத்தி நமது தேவைக்கு ஏற்றார்போல மாற்றிக்கொள்ள வழிவகை செய்கிறது (இயங்குதளத்தினை உடைக்காமல்).

வட்டுகள் (Disks) பயன்பாட்டினை பயன்பாட்டு ஏவி (launcher) துணைகொண்டு இயக்க (disks) என பயன்பாட்டு ஏவியில் தேடவும்.

மேற்கண்ட துவக்கபட்டியில் காட்டபட்டுள்ளது போல வட்டுக்கள்(Disks) பயன்பாடு தோன்றும். அந்தப் பயன்பாட்டினை திறக்கையில் கீழே காட்டபட்டுள்ளது போல பட்டியலிடப்பட்டு வன்வட்டுக்களும் திடநிலை வட்டுக்களும் தோன்றும்.

நான் இரண்டாவது வன்வட்டினை சொடுக்குகையில் அதில் உள்ள வன்வட்டின் பகுதிகள் (Partitions) திரையில் காட்டப்படும்.

அதில் நாம் தானமைவாக இணையக்கூடிய அமைப்பை கட்டமைக்க அந்த வட்டினை தேர்வு செய்து இணைக்கவேண்டிய பகுதியையும் தெரிவு செய்துகொள்ளவேண்டும்.

அப்போது வன்வட்டின் பகுதிகளின் கீழ் ஒரு மூன்று தேர்வுகள் தோன்றும்.

முதல் தேர்வு – இயங்குதளத்தில் இணை (Mount)

இரண்டாம் தேர்வு – பகுதியை நீக்கு (Delete Partition) (தேர்வினை தேர்வுசெய்துவிடாதீர்கள் வன்வட்டின் அந்தபகுதியில் உள்ள தரவுகள் அனைத்தும் நீக்கப்பட்டு ஒதுக்கப்படாத நினைவிடமாக மாற்றப்பபட்டுவிடும்)

மூன்றாம் தேர்வு – பிற அமைப்புகளை இந்த தெரிவில் காணலாம்.

மூன்றாவது தேர்வினை சொடுக்கினால் ஒரு சுறுக்குப்பட்டி(Context Menu) விரியும் அதில் இணைக்கும் தெரிவுகளை திருத்து (Edit Mount Options) எனும் தொடுப்பை அழுத்தினால் இணைக்கும் தெரிவுகள் உரையாடல் பெட்டி(Dialog Box) தோன்றும்.

இணைக்கும் தெரிவுகள் உரையாடல் பெட்டியில் இருப்பவை எல்லாம் பயன்படுத்தா இயலா நிலையில் (grayed out) காட்சியளிக்கும்.

இதனைப் பயன்படுத்தும் நிலைக்கு கொணற பயனை அமர்வு இயல்புநிலை (User Session Default) அமைப்புகளை மாற்று பொத்தான் (toggle button) பயன்படுத்தி மாற்றும் போது எல்லா அமைப்புகளும் திருத்தகக் கூடிய நிலையில் மாறிவிடும். பின்னர் அதனை சேமித்தால் அந்த வன்வட்டின் பகுதி தானமைவாகவே இயங்குதளத்தின் தொடக்கத்தில் இணைக்கப்பட்டுவிடும்.

நன்றி

அடுக்கு பரிமாற்றம் (stack exchange) : https://askubuntu.com/questions/164926/how-to-make-partitions-mount-at-startup

முனையத்தில் பகுதிகளை இணைக்கும் வழிமுறையை மற்றொரு பதிவில் காணலாம்.

Docker : Creating and uploading docker image to docker hub – டாக்கர் படத்தை உருவாக்கி அதை டாக்கர் ஹப்பில் பதிவேற்றுதல்

By: Hariharan
25 September 2024 at 20:00

செப் 25, 2024

நான் டாக்கர் வகுப்பில் கற்றவற்றை வைத்து ஒரு டாக்கர் படத்தை டாக்கர் ஹப்பில் பதிவேற்றுதல் வரை நடந்த செயல்பாடுகளை இந்தப்பதிவில் குறிப்பிடுகிறேன்.

டாக்கர் ஹப் கணக்கை துவக்குதல்

https://app.docker.com/signup இணைப்பை சொடுக்கவும் அதில் கூகுள் கணக்கை வைத்து (நீங்கள் பிற உள்நுழைவு அமைப்புகளையும் பயன்படுத்திக் கொள்ளலாம்) உள்நுழையவும்.

வெற்றிகரமான உள்நுழைவுக்கு பிறகு https://hub.docker.com க்கு Docker Hub Link ஐ சொடுக்குவதுமூலம் செல்லவும்.

Click the Docker Hub Link

டாக்கர் ஹப்பில் நாம் படத்தை பதிவேற்றம் செய்யும் முன்னர் அதனை பதிவேற்ற ஒரு கோப்புறை ஒன்றை உருவாக்க வேண்டும்.

கோப்புறைஐ உருவாக்கிய பிறகு நாம் நமது கணினியில் டாக்கர் படத்தை உருவாக்கிய பின்னர் அதனை பதிவேற்றிக்கொள்ளலாம்.

கணிணியில் ஒரு டாக்கர் படத்தை உருவாக்குதல்

முதலில் டாக்கர் படத்தை உருவாக்கும் முன்னர் பழைய டாக்கர் கலன்களின் (Container) இயக்கத்தை நிறுத்திவிட்டு சற்று நினைவத்தினை தயார் செய்து கொள்கிறேன் (நினைவக பற்றாக்குறை இருப்பதால்).

docker rm $(docker ps -aq)

பின்னர் Dockerfile எழுத துவங்க வேண்டியதுதான்

டாக்கர் படத்தை உருவாக்க நமக்கு தேவயான சார்பு படங்களை முதலில் பதிவிறக்கி அதனை தயார்படுத்திக்கொள்வோம்.

என்னுடய டாக்கர் படம் மிகவும் சிறியதாக வேண்டும் என நினைப்பதால் நான் python3-alpine பயன்படுத்துகிறேன்.

https://hub.docker.com/r/activestate/python3-alpine

நிறுவல் சரிபார்த்தல்

மேற்கண்ட கட்டளைவரிகளை பயன்படுத்தி நாம் நமது நிறுவலை சரிபார்க்கலாம்.

டாக்கர் கோப்பை எழுதுதல் மற்றும் டாக்கர் படத்தை உருவாக்குதல்

# we are choosing the base image as python alpine
FROM activestate/python3-alpine:latest
# setting work directory
WORKDIR ./foss-event-aggregator
# Copying the workdirectory files to the container 
COPY ./foss-event-aggregator ./foss-event-aggregator
# Installing required dev-dependencies 
# RUN ["pip3","install","-r","./foss-event-aggregator/dev-requirements.txt"]
# Running PIP commands to update the dependencies for the
RUN ["apk","add","libxml2-dev","libxslt-dev","python-dev"]

RUN ["pip3","install","-r","./foss-event-aggregator/requirements.txt"]

CMD ["python","eventgator.py"]

டாக்கர் கோப்பு எழுதும் போது தேவையான சார்புகள் அனைத்தும் சரியாக நிறுவப்படுகிறதா என்பதை சரிபார்க்க பிழைச்செய்தி வரும்போது அதனை சரிசெய்ய டாக்கர் கோப்பை தேவைப்படி மாற்றுக.

வெற்றிகரமாக foss-event-aggregator எனும் டாக்கர் படம் உருவாக்கப்பட்டது.

உருவாக்கப்பட்ட படத்தை பரிசோதித்தாகிவிட்டது இப்பொழுது டாக்கர் ஹப்புக்கு பதிவேற்றலாம்.

டாக்கர் ஹப்புக்கு பதிவேற்றுதல்

படத்தை பரிசோதித்த பிறகு கோப்புறை பெயரில் டாக் செய்யவேண்டும்

docker image tag foss-event-aggregator:v1 itzmrevil/foss-events-aggregator:v1

டாக் செய்யபட்ட பிறகு டாக்கரில் CLIல் உள்நுழைவு செய்து டாக்கரில் பதிவேற்றம் செய்தால் மட்டுமே டாக்கர் ஏற்றுக்கொள்ளும்.

டாக்கரில் உள்நுழைய

docker login

கொடுத்து டெர்மினலில் வரும் படிகளை பின்பற்றவும்.

உள்நுழைவு செய்த பின்னர்

docker push itzmrevil/foss-events-aggregator:v1

கட்டளையை கொடுத்து டாக்கர் படத்தை பதிவேற்றவும்

பதிவேற்றம் செய்யபட்டதை டாக்கர் ஹப்பில் பார்க்க https://hub.docker.com/repository/docker/itzmrevil/foss-events-aggregator/general

வெற்றி ! வெற்றி !! வெற்றி !!!

Docker : Virtual Machines – மெய்நிகர் இயந்திரங்கள்

By: Hariharan
25 September 2024 at 16:54

செப் 25, 2024

ஒரு கணிணியில் ஒரு வலைப்பயன்பாடினை இயங்குவதற்கு 4 பயன்பாடுகள் பயன்படுத்த வேண்டுமெனில் அந்த பயன்பாடு இயக்கத்திற்காக சார்ந்திருக்கும் நுண்செயலி(CPU), நினைவகம்(RAM), சேமிப்பக (Storage) போன்ற வன்பொருள் தேவைகளை பூர்த்தி செய்ய வேண்டும்.

இதே தேவைகளை சில சமயங்களில் பயனர்களின் (Users) எண்ணிக்கைக்கு ஏற்றவாறும் பயன்பாட்டின் அளவுகளுக்கு (Usage) ஏற்றவாறு நாம் அதிகப்படுத்த (Scaling) வேண்டியுமுள்ளது.

ஓரே கணிணியில் அதிகளவு பயனர்களின் அணுகல்களை அனுமதித்தால் அதிகபயன்பாட்டின் காரணமாக வலைதளங்கள் முடங்கும் அபாயம் உள்ளது.இதனை தவிர்க்க தனித்தனி இயந்திரங்களை பயன்படுத்தும் போது தேவைக்கு அதிகமாக வன்பொருள் மீதமிருக்கும் அது முழுவதுமாக பயன்படுத்தப் படாமலும் இருக்கும் (proper utilisation).

எடுத்துக்காட்டாக கீழ்வரும் 4 பயன்பாடுகளை

  • அப்பாச்சி வலை சேவையகம்
  • கிராப் கிகுவெல் எந்திரம்
  • போஸ்டுகிறீஸ் தரவுதள அமைப்பு
  • எக்ஸ்பிரஸ் வலைச் சேவையகம்

ஒரு கணிணியில் இயக்குவற்கு 4 GB (RAM), 2 Core (CPU) மற்றும் 250 GB (Storage) தேவைப்படும் என வைத்துக்கொள்வோம்.

நம்மிடம் 16 GB (RAM), 16 Core (CPU) மற்றும் 1000 GB கொண்ட கணினி உள்ளது அதில் இரண்டு நிறுவல்களை அமைத்து சோதணை செய்து பார்க்க மெய்நிகர் இயந்திரங்கள் கருத்துரு வழிவகை செய்கிறது.

ஆகவே ஒரு கணினியில் வன்பொருள் அமைப்புகளை தேவைகளைப் பொறுத்து ஒரு கணினியை பல கணினிகளாக மாற்றி சோதனை செய்து பயன்படுத்தும்போது அந்த கணிணிகளை மெய்நிகர் இயந்திரங்கள் எனப் பொருள் கொள்ளலாம்.

சி -நிரலாக்கம் பற்றிய சில கேள்விகள்:

By: Hariharan
13 September 2020 at 18:28

நிரலாக்கம் என்றால் என்ன?

நிரலாக்கம் என்பது கணினிக்கும் நமக்கும் தெரிந்த உயர்நிலை மொழியில் கட்டளைகளை எழுதுதல் ஆகும்.

சி-மொழிபெயர்ப்பி என்றால் என்ன?

சி-மொழிபெயர்ப்பி என்பது நீங்கள் எழுதும் நிரல்களை கணினிக்கு புரியும் கட்டளைகளாக மாற்றும் ஒரு மென்பொருள்.

சி-மொழிபெயர்பியை எவ்வாறு நிறுவுவது?

கணினியில் சி – மொழிபெயர்ப்பியை நிறுவுதல்:

உங்களின் கணினியின் இயங்கு தளத்திற்கு ஏற்ற மொழிப்பெயர்ப்பியை இணையத்திலிருந்து பதிவிறக்கம் செய்துகொள்ளவும்

வ.எண்இயங்குதளம் சி-மொழிபெயர்ப்பி இணைப்பு
1விண்டோஸ் 10/8/7C-Complier For Windows MS-DOS
Code Blocks IDE Download Page
அட்டவணை-1 இயங்குதளங்கள் அவற்றிற்காண சி-மொழிப்பெயர்ப்பிகள்

தரவிறக்கம் செய்யப்பட்ட கோப்பினை திறந்து உங்களுடய கணினியில் நிறுவிக்கொள்ளவும்.

மேலும் விவரங்களுக்கு சந்தா பெறவும்.

Docker : Meet & Greet – அறிமுக வகுப்பு

By: Hariharan
16 September 2024 at 18:48

செப் 16, 2024

நேற்று (15-09-2024) காஞ்சிலக் சந்திப்பு முடித்தவுடன் docker வகுப்பில் இணைந்தேன்.

வகுப்பில் இணைந்தவர்கள் அனைவரும் தத்தம் அறிமுகங்களை வழங்கிய பிறகு ஜாபர் அவர்கள் docker ன் பண்புக்கூறுகளை விளக்கினார்.

பின்னர் வின்டோஸில் docker ஐ எப்படி நிறுவுவது குறித்து விளக்கினார்.

சிலரின் கணினியில் docker நிறுவுதலில் பிழைச்செய்தி வந்ததையடுத்து அதனை சரிசெய்து வகுப்பை முடித்துகொண்டோம்.

#மாயோன்_மேய_ஓண_நல்_நாள்..!!!🤩🙏

16 September 2024 at 03:59

"கணம்கொள் அவுணர்க் கடந்த பொலந்தார்
மாயோன் மேய ஓண நல் நாள்,
கோணம் தின்ற வடு ஆழ் முகத்த,
சாணம் தின்ற சமம் தாங்கு தடக்கை,
மறம் கொள் சேரி மாறு பொரு செருவில்,
மாறாது உற்ற வடுப் படு நெற்றி,
சுரும்பு ஆர் கண்ணிப் பெரும் புகல் மறவர்
கடுங் களிறு ஓட்டலின், காணுநர் இட்ட
நெடுங் கரைக் காழகம் நிலம் பரல் உறுப்ப,
கடுங்கள் தேறல் மகிழ் சிறந்து திரிதர'' (ம.கா.590-599)

என்ற மதுரைக்காஞ்சி பாடலடிகள் மெய்பிக்கின்றன. ஓண நன்னாளன்று காய்கறி, கனி முதலிய உணவுப் பொருள்களை விருந்தினருக்குக் கொடுத்து மகிழ்ந்திருந்தனர். வீரர்கள் "சேரிப்போர்' என்னும் வீர விளையாட்டை நிகழ்த்தினர் என்றும், வெற்றி பெற்ற வீரர்களுக்குப் பசுக்களைப் பாண்டிய மன்னன் வழங்கினான் என்றும் மதுரையில் நடைபெற்ற ஓணம் பண்டிகையை விளக்கியுள்ளார் மாங்குடி
மருதனார்.

இறையனார் களவியல் உரைக்காரர் நக்கீரர், தமிழ்நாட்டில் நடைபெற்ற திருவிழாக்களைக் கூறுமிடத்து ""மதுரை ஆவணி அவிட்டமே, உறையூர்ப் பங்குனி உத்திரமே, கருவூர் உள்ளி விழாவே என இவையும்'' என்று குறிப்பிடுகிறார். இவர் குறிப்பிடும் மதுரை ஆவணி அவிட்டம், திருவோணத் திருவிழாவையே குறிப்பதாக மு.இராகவையங்கார் கருதுகிறார்.
தமிழ் நாட்டில் நடைபெற்ற ஓணம் பண்டிகையைப் பெரியாழ்வாரும் திருஞானசம்பந்தரும் குறிப்பிடுகிறார்கள். திருமாலுக்கு உரிய நாள் திருவோணம் என்ற போதிலும், சென்னை - மயிலாப்பூர் கபாலீசுவரர் திருக்கோயிலில் திருவோண விழா நடைபெற்ற செய்தியை திருஞானசம்பந்தர் குறிப்பிடுகிறார்.

தமிழகத்தில் பண்டைக் காலத்தில் சிறப்பாக நடைபெற்ற இந்த ஓணம் பண்டிகை, பின்னர் ஏனோ வழக்கொழிந்து போயிற்று. ஆனால், இன்று ஓணம் பண்டிகை கேரளா முழுவதும் விழாக் கோலம் பூண்டு இன்பத் திருவிழாவாகக் கொண்டாடப்பெற்று வருகிறது.

பதிவு: நன்பர் செல்வா முகபுத்தகத்தில் இருந்து

தமிழ் வாழ்க
ஈ. பாலகதிரேசன் @ கதிர்

Kanchi-LUG Weekly Discussion 08-09-2024 Summary & My Experiments : )

By: Hariharan
14 September 2024 at 19:52

Talk 0:
Topic : MiniDLNA media server.
Name : Syed Jafer

எமது பைத்தான் வகுப்பின் பயிற்றுனர் செய்யது ஜாபர் தன்னுடைய கணினியில் miniDLNA பல்லூடக வழங்கி (media server) நிறுவுதல் குறித்தும் அதன் பயன்பாடுகள் குறித்தும் உரை வழங்கினார்.

அந்த பயன்பாட்டினை என்னுடைய உபுண்டு இயங்குதளத்தில் நிறுவியது குறித்து இப்பதிவில் காணலாம்.

எந்த பயன்பாட்டையும் உபுண்டு இயங்குதளத்தில் நிறுவல் செய்யவேண்டி இயங்குதளத்தினை நிகழ்நிலைப்படுத்தினேன் (updating)

sudo apt update

இயங்குதளத்தினை நிகழ்நிலைப்படுத்திய பிறகு

sudo apt install minidlna

நிறுவல் நல்லபடியாக முடிந்தது.

இப்பொழுது பல்லுடக வழங்கியைநமக்கு தேவைப்படும் படி கட்டமைத்துகொள்ளும் படிகளை ஒவ்வொன்றாக பார்க்கலாம்.

என்னுடைய கணிணியில் ஒரு பயனறே உள்ளபடியால் அவருக்கு மட்டும் நிறுவலைக் கட்டமைப்பு செய்வோம். பின்னர் பல்லூடக கோப்புகளின் இருப்பிடங்களை கட்டமைப்பு செய்வோம்.

எப்பொழுதும் கணினியில் கட்டமைவை மாற்றும் போது அதனை ஒரு காப்புபிரதி (backup) எடுத்து பயன்படுத்துதல் நன்று.

#media_dir=/var/lib/minidlna
media_dir=A,/home/hariharan/Music
media_dir=V,/home/hariharan/Videos
media_dir=P,/home/hariharan/Pictures
db_dir=/var/cache/minidlna

log_dir=/var/log/minidlna (create folder manually if not created automatically)

friendly_name=UbuntuMediaServer

மேற்கண்ட வரிகளில்

media_dir என்பது பல்லூடக கோப்புகளை வழங்கியில் காண்பிப்பதற்கான கட்டமைவு ஆகும்.

db_dir என்பது கோப்புகளின் பிற விவரங்களை சேமித்துவைக்க வழங்கி பயன்படுத்தும் கோப்புறை

log_dir என்பது வழங்கி பிழைச்செய்திமற்றும் பிற முக்கிய பயன்பாட்டின் நிகழ்வுகளை பதியும் கோப்புறை

friendly_name என்பது நமது வழங்கிக்கு நாம் வழங்கும் பெயர். பிற dlna நெறிமுறை மூலம் இயங்கும் பயன்பாடுகள் நமது வழங்கியை பயன்படுத்தும் போது இந்த பெயரின் கீழ் கோப்புகளை வழங்கும்.

எனது பரிசோதனைகள்

  1. MX Player – Android லிருந்து பல்லூடக வழங்கியை அணுகுதல்.

முடிவு: பல்லுடக வழங்கியை அனுகமுடியவில்லை.

  1. serveo.net பயன்படுத்தி பல்லூடக வழங்கியை அணுகுதல்.

முடிவு: பல்லூடக வழங்கியை அணுகமுடியவில்லை

Kanchi-LUG Weekly Discussion 08-09-2024 Summary & My Experiments : )

By: Hariharan
14 September 2024 at 19:49

Talk 0:
Topic : MiniDLNA media server.
Name : Syed Jafer

எமது பைத்தான் வகுப்பின் பயிற்றுனர் செய்யது ஜாபர் தன்னுடைய கணினியில் miniDLNA பல்லூடக வழங்கி (media server) நிறுவுதல் குறித்தும் அதன் பயன்பாடுகள் குறித்தும் உரை வழங்கினார்.

அந்த பயன்பாட்டினை என்னுடைய உபுண்டு இயங்குதளத்தில் நிறுவியது குறித்து இப்பதிவில் காணலாம்.

எந்த பயன்பாட்டையும் உபுண்டு இயங்குதளத்தில் நிறுவல் செய்யவேண்டி இயங்குதளத்தினை நிகழ்நிலைப்படுத்தினேன் (updating)

sudo apt update

இயங்குதளத்தினை நிகழ்நிலைப்படுத்திய பிறகு

sudo apt install minidlna

நிறுவல் நல்லபடியாக முடிந்தது.

இப்பொழுது பல்லுடக வழங்கியைநமக்கு தேவைப்படும் படி கட்டமைத்துகொள்ளும் படிகளை ஒவ்வொன்றாக பார்க்கலாம்.

என்னுடைய கணிணியில் ஒரு பயனறே உள்ளபடியால் அவருக்கு மட்டும் நிறுவலைக் கட்டமைப்பு செய்வோம். பின்னர் பல்லூடக கோப்புகளின் இருப்பிடங்களை கட்டமைப்பு செய்வோம்.

எப்பொழுதும் கணினியில் கட்டமைவை மாற்றும் போது அதனை ஒரு காப்புபிரதி (backup) எடுத்து பயன்படுத்துதல் நன்று.

#media_dir=/var/lib/minidlna
media_dir=A,/home/hariharan/Music
media_dir=V,/home/hariharan/Videos
media_dir=P,/home/hariharan/Pictures
db_dir=/var/cache/minidlna

log_dir=/var/log/minidlna (create folder manually if not created automatically)

friendly_name=UbuntuMediaServer

மேற்கண்ட வரிகளில்

media_dir என்பது பல்லூடக கோப்புகளை வழங்கியில் காண்பிப்பதற்கான கட்டமைவு ஆகும்.

db_dir என்பது கோப்புகளின் பிற விவரங்களை சேமித்துவைக்க வழங்கி பயன்படுத்தும் கோப்புறை

log_dir என்பது வழங்கி பிழைச்செய்திமற்றும் பிற முக்கிய பயன்பாட்டின் நிகழ்வுகளை பதியும் கோப்புறை

friendly_name என்பது நமது வழங்கிக்கு நாம் வழங்கும் பெயர். பிற dlna நெறிமுறை மூலம் இயங்கும் பயன்பாடுகள் நமது வழங்கியை பயன்படுத்தும் போது இந்த பெயரின் கீழ் கோப்புகளை வழங்கும்.

எனது பரிசோதனைகள்

  1. MX Player – Android லிருந்து பல்லூடக வழங்கியை அணுகுதல்.

முடிவு: பல்லுடக வழங்கியை அனுகமுடியவில்லை.

  1. serveo.net பயன்படுத்தி பல்லூடக வழங்கியை அணுகுதல்.

முடிவு: பல்லூடக வழங்கியை அணுகமுடியவில்லை

ML Day 1: கற்கும் இயந்திரவியல் முதல் நாள் வகுப்பு

By: Hariharan
14 September 2024 at 17:39

பைத்தான் வகுப்பு முடிந்ததும் 7-8 நேரத்தை பிற நல்ல முறையில் பயன்படுத்த வேண்டும் என்ற ஆவல் இருந்தது.

அப்போது பைத்தான் வகுப்பு குழுவிலிருந்து ஒரு செய்தி வந்தது. கற்கும் இயந்திரவியலில் ஒரு அறிமுக 3 நாள் வகுப்பு தினமும் 8:30 – 9:30 என்ற அறிவிப்புதான் அது.

சரி இந்த முறையாவது அனைத்து வகுப்புகளையும் நேரலை அல்லாமல் நேரடியாக இணையவேண்டும் என்ற மன உறுதியுடன் வகுப்புகளில் இணைந்து வகுப்புகளை கவனித்தேன்.

இப்போது வகுப்பில் இருந்து கற்றவற்றை எளிதில் விளங்கும் கேள்வி பதிலாக தொகுத்து கூறும் முயற்சியில் இறங்கியுள்ளேன்.

  1. கற்கும் இயந்திரவியல் என்பது என்ன ?
  2. கற்கும் இயந்திரவியலை புரிந்து கொள்ள நமக்கு அடிப்படையாக தேவைப்படுபவை எவை?

மன்னிக்கவும்! .

இப்பதிவு இன்னும் முழுமையாக எழுதி முடிக்கப்படவில்லை.

Slicing in python programming

14 September 2024 at 15:53

slicing prpgramming
a="Avinash"
print(a[:])
b="keeramangalam"
print(b[3:])
c="Hello Avinash"
print(c[4:])
d="Hello world"
print(c[:4])
e="Keeramangalam"
print(e[:-2])
g="Keeramangalam"
print(g[-5:-2])
o/p
Avinash
ramangalam
o Avinash
Hell
Keeramangal
gal

HAProxy EP 9: Load Balancing with Weighted Round Robin

11 September 2024 at 14:39

Load balancing helps distribute client requests across multiple servers to ensure high availability, performance, and reliability. Weighted Round Robin Load Balancing is an extension of the round-robin algorithm, where each server is assigned a weight based on its capacity or performance capabilities. This approach ensures that more powerful servers handle more traffic, resulting in a more efficient distribution of the load.

What is Weighted Round Robin Load Balancing?

Weighted Round Robin Load Balancing assigns a weight to each server. The weight determines how many requests each server should handle relative to the others. Servers with higher weights receive more requests compared to those with lower weights. This method is useful when backend servers have different processing capabilities or resources.

Step-by-Step Implementation with Docker

Step 1: Create Dockerfiles for Each Flask Application

We’ll use the same three Flask applications (app1.py, app2.py, and app3.py) as in previous examples.

  • Flask App 1 (app1.py):

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello from Flask App 1!"

@app.route("/data")
def data():
    return "Data from Flask App 1!"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5001)

  • Flask App 2 (app2.py):

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello from Flask App 2!"

@app.route("/data")
def data():
    return "Data from Flask App 2!"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5002)

  • Flask App 3 (app3.py):

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello from Flask App 3!"

@app.route("/data")
def data():
    return "Data from Flask App 3!"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5003)

Step 2: Create Dockerfiles for Each Flask Application

Create Dockerfiles for each of the Flask applications:

  • Dockerfile for Flask App 1 (Dockerfile.app1):

# Use the official Python image from Docker Hub
FROM python:3.9-slim

# Set the working directory inside the container
WORKDIR /app

# Copy the application file into the container
COPY app1.py .

# Install Flask inside the container
RUN pip install Flask

# Expose the port the app runs on
EXPOSE 5001

# Run the application
CMD ["python", "app1.py"]

  • Dockerfile for Flask App 2 (Dockerfile.app2):

FROM python:3.9-slim
WORKDIR /app
COPY app2.py .
RUN pip install Flask
EXPOSE 5002
CMD ["python", "app2.py"]

  • Dockerfile for Flask App 3 (Dockerfile.app3):

FROM python:3.9-slim
WORKDIR /app
COPY app3.py .
RUN pip install Flask
EXPOSE 5003
CMD ["python", "app3.py"]

Step 3: Create the HAProxy Configuration File

Create an HAProxy configuration file (haproxy.cfg) to implement Weighted Round Robin Load Balancing


global
    log stdout format raw local0
    daemon

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    timeout connect 5000ms
    timeout client  50000ms
    timeout server  50000ms

frontend http_front
    bind *:80
    default_backend servers

backend servers
    balance roundrobin
    server server1 app1:5001 weight 2 check
    server server2 app2:5002 weight 1 check
    server server3 app3:5003 weight 3 check

Explanation:

  • The balance roundrobin directive tells HAProxy to use the Round Robin load balancing algorithm.
  • The weight option for each server specifies the weight associated with each server:
    • server1 (App 1) has a weight of 2.
    • server2 (App 2) has a weight of 1.
    • server3 (App 3) has a weight of 3.
  • Requests will be distributed based on these weights: App 3 will receive the most requests, App 2 the least, and App 1 will be in between.

Step 4: Create a Dockerfile for HAProxy

Create a Dockerfile for HAProxy (Dockerfile.haproxy):


# Use the official HAProxy image from Docker Hub
FROM haproxy:latest

# Copy the custom HAProxy configuration file into the container
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg

# Expose the port for HAProxy
EXPOSE 80

Step 5: Create a docker-compose.yml File

To manage all the containers together, create a docker-compose.yml file

version: '3'

services:
  app1:
    build:
      context: .
      dockerfile: Dockerfile.app1
    container_name: flask_app1
    ports:
      - "5001:5001"

  app2:
    build:
      context: .
      dockerfile: Dockerfile.app2
    container_name: flask_app2
    ports:
      - "5002:5002"

  app3:
    build:
      context: .
      dockerfile: Dockerfile.app3
    container_name: flask_app3
    ports:
      - "5003:5003"

  haproxy:
    build:
      context: .
      dockerfile: Dockerfile.haproxy
    container_name: haproxy
    ports:
      - "80:80"
    depends_on:
      - app1
      - app2
      - app3


Explanation:

  • The docker-compose.yml file defines the services (app1, app2, app3, and haproxy) and their respective configurations.
  • HAProxy depends on the three Flask applications to be up and running before it starts.

Step 6: Build and Run the Docker Containers

Run the following command to build and start all the containers


docker-compose up --build

This command builds Docker images for all three Flask apps and HAProxy, then starts them.

Step 7: Test the Load Balancer

Open your browser or use curl to make requests to the HAProxy server


curl http://localhost/
curl http://localhost/data

Observation:

  • With Weighted Round Robin Load Balancing, you should see that requests are distributed according to the weights specified in the HAProxy configuration.
  • For example, App 3 should receive three times more requests than App 2, and App 1 should receive twice as many as App 2.

Conclusion

By implementing Weighted Round Robin Load Balancing with HAProxy, you can distribute traffic more effectively according to the capacity or performance of each backend server. This approach helps optimize resource utilization and ensures a balanced load across servers.

HAProxy EP 8: Load Balancing with Random Load Balancing

11 September 2024 at 14:23

Load balancing distributes client requests across multiple servers to ensure high availability and reliability. One of the simplest load balancing algorithms is Random Load Balancing, which selects a backend server randomly for each client request.

Although this approach does not consider server load or other metrics, it can be effective for less critical applications or when the goal is to achieve simplicity.

What is Random Load Balancing?

Random Load Balancing assigns incoming requests to a randomly chosen server from the available pool of servers. This method is straightforward and ensures that requests are distributed in a non-deterministic manner, which may work well for environments with equally capable servers and minimal concerns about server load or state.

Step-by-Step Implementation with Docker

Step 1: Create Dockerfiles for Each Flask Application

We’ll use the same three Flask applications (app1.py, app2.py, and app3.py) as in previous examples.

Flask App 1 – (app.py)

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello from Flask App 1!"

@app.route("/data")
def data():
    return "Data from Flask App 1!"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5001)


Flask App 2 – (app.py)


from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello from Flask App 2!"

@app.route("/data")
def data():
    return "Data from Flask App 2!"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5002)

Flask App 3 – (app.py)

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello from Flask App 3!"

@app.route("/data")
def data():
    return "Data from Flask App 3!"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5003)


Step 2: Create Dockerfiles for Each Flask Application

Create Dockerfiles for each of the Flask applications:

  • Dockerfile for Flask App 1 (Dockerfile.app1):
# Use the official Python image from Docker Hub
FROM python:3.9-slim

# Set the working directory inside the container
WORKDIR /app

# Copy the application file into the container
COPY app1.py .

# Install Flask inside the container
RUN pip install Flask

# Expose the port the app runs on
EXPOSE 5001

# Run the application
CMD ["python", "app1.py"]

  • Dockerfile for Flask App 2 (Dockerfile.app2):
FROM python:3.9-slim
WORKDIR /app
COPY app2.py .
RUN pip install Flask
EXPOSE 5002
CMD ["python", "app2.py"]


  • Dockerfile for Flask App 3 (Dockerfile.app3):

FROM python:3.9-slim
WORKDIR /app
COPY app3.py .
RUN pip install Flask
EXPOSE 5003
CMD ["python", "app3.py"]

Step 3: Create a Dockerfile for HAProxy

HAProxy Configuration file,


global
    log stdout format raw local0
    daemon

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    timeout connect 5000ms
    timeout client  50000ms
    timeout server  50000ms

frontend http_front
    bind *:80
    default_backend servers

backend servers
    balance random
    random draw 2
    server server1 app1:5001 check
    server server2 app2:5002 check
    server server3 app3:5003 check

Explanation:

  • The balance random directive tells HAProxy to use the Random load balancing algorithm.
  • The random draw 2 setting makes HAProxy select 2 servers randomly and choose the one with the least number of connections. This adds a bit of load awareness to the random choice.
  • The server directives define the backend servers and their ports.

Step 4: Create a Dockerfile for HAProxy

Create a Dockerfile for HAProxy (Dockerfile.haproxy):

# Use the official HAProxy image from Docker Hub
FROM haproxy:latest

# Copy the custom HAProxy configuration file into the container
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg

# Expose the port for HAProxy
EXPOSE 80


Step 5: Create a docker-compose.yml File

To manage all the containers together, create a docker-compose.yml file:


version: '3'

services:
  app1:
    build:
      context: .
      dockerfile: Dockerfile.app1
    container_name: flask_app1
    ports:
      - "5001:5001"

  app2:
    build:
      context: .
      dockerfile: Dockerfile.app2
    container_name: flask_app2
    ports:
      - "5002:5002"

  app3:
    build:
      context: .
      dockerfile: Dockerfile.app3
    container_name: flask_app3
    ports:
      - "5003:5003"

  haproxy:
    build:
      context: .
      dockerfile: Dockerfile.haproxy
    container_name: haproxy
    ports:
      - "80:80"
    depends_on:
      - app1
      - app2
      - app3

Explanation:

  • The docker-compose.yml file defines the services (app1, app2, app3, and haproxy) and their respective configurations.
  • HAProxy depends on the three Flask applications to be up and running before it starts.

Step 6: Build and Run the Docker Containers

Run the following command to build and start all the containers:


docker-compose up --build

This command builds Docker images for all three Flask apps and HAProxy, then starts them.

Step 7: Test the Load Balancer

Open your browser or use curl to make requests to the HAProxy server:

curl http://localhost/
curl http://localhost/data

Observation:

  • With Random Load Balancing, each request should randomly hit one of the three backend servers.
  • Since the selection is random, you may not see a predictable pattern; however, the requests should be evenly distributed across the servers over a large number of requests.

Conclusion

By implementing Random Load Balancing with HAProxy, we’ve demonstrated a simple way to distribute traffic across multiple servers without relying on complex metrics or state information. While this approach may not be ideal for all use cases, it can be useful in scenarios where simplicity is more valuable than fine-tuned load distribution.

❌
❌