[{"data":1,"prerenderedAt":10992},["ShallowReactive",2],{"all-blogs":3},[4,1707,2965,4040,6317,8473,9620,9922,10457,10739],{"id":5,"title":6,"body":7,"date":1691,"description":1692,"draft":1693,"extension":1694,"image":42,"meta":1695,"navigation":977,"path":1696,"seo":1697,"stem":1698,"tags":1699,"__hash__":1706},"blogs\u002Fblogs\u002Fdns_explained_the_backbone_of_the_world_wide_web\u002Findex.md","DNS Explained: The Backbone of the World Wide Web",{"type":8,"value":9,"toc":1634},"minimark",[10,14,17,20,33,36,43,48,51,54,57,62,67,70,103,106,120,123,126,137,140,145,153,161,164,168,171,181,184,187,190,193,241,244,247,251,254,257,268,271,286,289,293,296,299,335,338,353,357,360,364,367,370,374,377,397,400,404,407,418,421,425,428,432,435,439,442,446,449,452,456,459,462,466,469,472,476,479,485,488,492,495,499,502,510,514,517,523,527,530,536,540,543,549,552,556,559,565,569,572,578,582,585,591,595,598,604,607,611,614,620,624,627,638,641,645,648,662,665,669,672,698,701,705,708,711,715,718,722,725,745,748,752,755,769,772,776,781,784,788,791,795,798,802,805,809,826,830,833,837,844,1158,1161,1177,1181,1188,1192,1195,1219,1222,1286,1290,1293,1320,1323,1327,1330,1358,1362,1382,1385,1389,1392,1396,1400,1417,1421,1435,1439,1442,1469,1473,1476,1487,1490,1494,1498,1515,1519,1533,1537,1554,1557,1561,1614,1618,1621,1624,1627,1630],[11,12,13],"p",{},"Domain Name System ( DNS ) is one of the most critical infrastructure pieces of the internet. Every website visit, API call, or email delivery begins with a DNS query.",[11,15,16],{},"While most organizations rely on managed DNS providers, self-hosting a DNS nameserver can be a powerful learning experience and, in some cases, a practical solution for greater control, privacy, or experimentation.",[11,18,19],{},"In this blog, we will:",[21,22,23,27,30],"ul",{},[24,25,26],"li",{},"Understand how DNS works at a global scale",[24,28,29],{},"Explore real-world DNS architecture and infrastructure",[24,31,32],{},"Walk through self-hosting an authoritative DNS server using PowerDNS",[11,34,35],{},"This article is aimed at system administrators, DevOps engineers, and curious learners who want to go deeper than “just use a managed DNS provider.”",[11,37,38],{},[39,40],"img",{"alt":41,"src":42},"dns","\u002Fimages\u002Fblogs\u002Fdns_explained_the_backbone_of_the_world_wide_web\u002Fdns.png",[44,45,47],"h2",{"id":46},"what-problem-dns-solves","What Problem DNS Solves ?",[11,49,50],{},"At its core, DNS exists to solve a human problem, not a technical one.",[11,52,53],{},"Computers are extremely good at working with numbers. Humans are not.",[11,55,56],{},"The internet, however, must work for both.",[39,58],{"src":59,"style":60,"alt":61},"\u002Fimages\u002Fblogs\u002Fdns_explained_the_backbone_of_the_world_wide_web\u002Fip_communication.png","display:block; margin-left:auto; margin-right:auto","IP communication diagram",[63,64,66],"h3",{"id":65},"why-humans-cannot-use-ip-addresses","Why Humans Cannot Use IP Addresses ?",[11,68,69],{},"Every device connected to the internet is identified by an IP address, such as:",[71,72,77],"pre",{"className":73,"code":74,"language":75,"meta":76,"style":76},"language-bash shiki shiki-themes github-light","IPv4: 37.27.249.121\nIPv6: 2001:db8:85a3::8a2e:370:7334\n","bash","",[78,79,80,93],"code",{"__ignoreMap":76},[81,82,85,89],"span",{"class":83,"line":84},"line",1,[81,86,88],{"class":87},"s7eDp","IPv4:",[81,90,92],{"class":91},"sYu0t"," 37.27.249.121\n",[81,94,96,99],{"class":83,"line":95},2,[81,97,98],{"class":87},"IPv6:",[81,100,102],{"class":101},"sYBdl"," 2001:db8:85a3::8a2e:370:7334\n",[11,104,105],{},"While these numbers are efficient for machines, they are fundamentally unsuitable for humans:",[21,107,108,111,114,117],{},[24,109,110],{},"They are hard to remember",[24,112,113],{},"They have no semantic meaning",[24,115,116],{},"They change frequently (cloud, load balancers, failovers)",[24,118,119],{},"IPv6 addresses are even longer and more complex",[11,121,122],{},"Humans think in names, not numbers.",[11,124,125],{},"We remember:",[21,127,128,131,134],{},[24,129,130],{},"google.com",[24,132,133],{},"github.com",[24,135,136],{},"example.com",[11,138,139],{},"Not:",[21,141,142],{},[24,143,144],{},"142.250.195.78",[11,146,147,148,152],{},"The core problem DNS solves is ",[149,150,151],"strong",{},"decoupling identity from location",":",[21,154,155,158],{},[24,156,157],{},"A name represents a service or organization",[24,159,160],{},"An IP address represents where that service currently lives",[11,162,163],{},"This separation allows infrastructure to evolve without breaking human access.",[63,165,167],{"id":166},"why-centralized-name-mapping-doesnt-scale","Why Centralized Name Mapping Doesn’t Scale ?",[11,169,170],{},"In the very early days of the internet, name resolution was centralized.",[11,172,173,174,177,178],{},"There was a single file: ",[78,175,176],{},"HOSTS.txt"," or ",[78,179,180],{},"\u002Fetc\u002Fhosts",[11,182,183],{},"Every hostname and IP mapping lived in this file, maintained by a central authority.",[11,185,186],{},"Each computer periodically downloaded the latest version.",[11,188,189],{},"This approach worked — until it didn’t.",[11,191,192],{},"The Problems with Centralization :",[21,194,195,203,211,222,233],{},[24,196,197,198],{},"Single Point of Failure\n",[21,199,200],{},[24,201,202],{},"If the central server went down, name resolution stopped",[24,204,205,206],{},"Administrative Bottleneck\n",[21,207,208],{},[24,209,210],{},"Every new host required manual approval and distribution",[24,212,213,214],{},"Update Latency\n",[21,215,216,219],{},[24,217,218],{},"Changes propagated slowly",[24,220,221],{},"Stale data caused outages",[24,223,224,225],{},"No Delegation\n",[21,226,227,230],{},[24,228,229],{},"One organization controlled all names",[24,231,232],{},"No ownership model",[24,234,235,236],{},"Security Risk\n",[21,237,238],{},[24,239,240],{},"Anyone who compromised the central file could hijack the entire internet",[11,242,243],{},"As the number of connected machines grew from hundreds to millions and now billions this model became impossible.",[11,245,246],{},"The internet needed a distributed naming system.",[63,248,250],{"id":249},"why-dns-must-be-distributed","Why DNS Must Be Distributed ?",[11,252,253],{},"DNS is distributed by design because no single system can know everything.",[11,255,256],{},"Instead:",[21,258,259,262,265],{},[24,260,261],{},"Responsibility is split",[24,263,264],{},"Authority is delegated",[24,266,267],{},"Queries are answered locally whenever possible",[11,269,270],{},"Each domain owner controls their own namespace:",[21,272,273,278,283],{},[24,274,275,276],{},"Google controls ",[78,277,130],{},[24,279,280,281],{},"GitHub controls ",[78,282,133],{},[24,284,285],{},"You control your domain",[11,287,288],{},"There is no “master DNS database” for the internet and that is intentional.",[63,290,292],{"id":291},"why-dns-is-hierarchical","Why DNS Is Hierarchical ?",[11,294,295],{},"Distribution alone is not enough. Without structure, discovery would still be inefficient.",[11,297,298],{},"DNS solves this with hierarchy.",[71,300,302],{"className":73,"code":301,"language":75,"meta":76,"style":76},".\n└── com\n    └── example\n        └── www\n",[78,303,304,309,317,326],{"__ignoreMap":76},[81,305,306],{"class":83,"line":84},[81,307,308],{"class":91},".\n",[81,310,311,314],{"class":83,"line":95},[81,312,313],{"class":87},"└──",[81,315,316],{"class":101}," com\n",[81,318,320,323],{"class":83,"line":319},3,[81,321,322],{"class":87},"    └──",[81,324,325],{"class":101}," example\n",[81,327,329,332],{"class":83,"line":328},4,[81,330,331],{"class":87},"        └──",[81,333,334],{"class":101}," www\n",[11,336,337],{},"A strong deep-technical blog must move through four layers:",[339,340,341,344,347,350],"ol",{},[24,342,343],{},"Conceptual model – what DNS is and why it exists",[24,345,346],{},"Real internet behavior – how DNS works globally",[24,348,349],{},"Hands-on mechanics – commands, configs, files",[24,351,352],{},"Operational reality – security, failure modes, best practices",[44,354,356],{"id":355},"dns-hierarchy-in-detail","DNS Hierarchy in Detail",[11,358,359],{},"DNS is organized as an inverted tree structure, starting from the root and branching down to individual domains. This hierarchy ensures efficient delegation and scalability.",[63,361,363],{"id":362},"root-servers","Root Servers",[11,365,366],{},"At the top of the DNS hierarchy are the root servers. There are 13 logical root server clusters (labeled A through M), operated by different organizations worldwide. These servers maintain the master list of all top-level domains (TLDs).",[11,368,369],{},"Root servers don't contain actual domain records but point resolvers to the authoritative servers for each TLD. They respond with NS records directing queries to the appropriate TLD servers.",[63,371,373],{"id":372},"top-level-domains-tlds","Top-Level Domains (TLDs)",[11,375,376],{},"TLDs are the highest level of domain names, appearing after the last dot. They are divided into categories:",[21,378,379,385,391],{},[24,380,381,384],{},[149,382,383],{},"gTLDs (Generic TLDs):"," .com, .org, .net, .info, .biz",[24,386,387,390],{},[149,388,389],{},"ccTLDs (Country Code TLDs):"," .us, .uk, .de, .in, .jp",[24,392,393,396],{},[149,394,395],{},"New gTLDs:"," .app, .dev, .tech, .blog",[11,398,399],{},"Each TLD has its own set of authoritative name servers managed by registries (like Verisign for .com or individual country registries).",[63,401,403],{"id":402},"authoritative-name-servers","Authoritative Name Servers",[11,405,406],{},"For each domain, there are authoritative name servers that hold the actual DNS records. These are typically provided by:",[21,408,409,412,415],{},[24,410,411],{},"Domain registrars (when you register a domain)",[24,413,414],{},"DNS hosting providers (like Cloudflare, Route 53, DigitalOcean)",[24,416,417],{},"Self-hosted servers (for organizations with their own infrastructure)",[11,419,420],{},"Authoritative servers are the source of truth for a domain's records and are responsible for responding to queries about that domain.",[44,422,424],{"id":423},"dns-resolution-process-step-by-step","DNS Resolution Process: Step-by-Step",[11,426,427],{},"When you type \"example.com\" into your browser, a complex resolution process occurs behind the scenes. Let's trace through a typical DNS lookup:",[63,429,431],{"id":430},"step-1-local-cache-check","Step 1: Local Cache Check",[11,433,434],{},"Your operating system and browser maintain a DNS cache. The resolver first checks these local caches for the requested domain. If found and not expired, it returns the cached IP address immediately.",[63,436,438],{"id":437},"step-2-recursive-resolver-query","Step 2: Recursive Resolver Query",[11,440,441],{},"If not cached locally, your device queries a recursive DNS resolver (usually provided by your ISP, or public ones like 8.8.8.8 or 1.1.1.1). This resolver acts on your behalf to find the answer.",[63,443,445],{"id":444},"step-3-root-server-query","Step 3: Root Server Query",[11,447,448],{},"The recursive resolver starts at the root. It queries one of the 13 root servers asking \"Who handles .com domains?\"",[11,450,451],{},"The root server responds with NS records pointing to the TLD servers for .com.",[63,453,455],{"id":454},"step-4-tld-server-query","Step 4: TLD Server Query",[11,457,458],{},"The resolver queries the .com TLD servers: \"Who handles example.com?\"",[11,460,461],{},"The TLD server responds with NS records pointing to example.com's authoritative servers.",[63,463,465],{"id":464},"step-5-authoritative-server-query","Step 5: Authoritative Server Query",[11,467,468],{},"Finally, the resolver queries example.com's authoritative servers: \"What is the IP address for example.com?\"",[11,470,471],{},"The authoritative server returns the A or AAAA record with the IP address.",[63,473,475],{"id":474},"step-6-response-and-caching","Step 6: Response and Caching",[11,477,478],{},"The recursive resolver returns the IP to your device, which caches it. Future requests for the same domain will be served from cache until expiration.",[11,480,481],{},[39,482],{"alt":483,"src":484},"DNS Resolution","\u002Fimages\u002Fblogs\u002Fdns_explained_the_backbone_of_the_world_wide_web\u002Fweb_request.png",[11,486,487],{},"This process typically takes 20-100ms and involves multiple network round trips across the globe.",[44,489,491],{"id":490},"dns-record-types","DNS Record Types",[11,493,494],{},"DNS stores different types of records, each serving a specific purpose. Here are the most common ones:",[63,496,498],{"id":497},"a-record-address-record","A Record (Address Record)",[11,500,501],{},"Maps a domain name to an IPv4 address.",[71,503,508],{"className":504,"code":506,"language":507},[505],"language-text","example.com.    IN  A   93.184.216.34\n","text",[78,509,506],{"__ignoreMap":76},[63,511,513],{"id":512},"aaaa-record-ipv6-address-record","AAAA Record (IPv6 Address Record)",[11,515,516],{},"Maps a domain name to an IPv6 address.",[71,518,521],{"className":519,"code":520,"language":507},[505],"example.com.    IN  AAAA   2606:2800:220:1:248:1893:25c8:1946\n",[78,522,520],{"__ignoreMap":76},[63,524,526],{"id":525},"cname-record-canonical-name","CNAME Record (Canonical Name)",[11,528,529],{},"Creates an alias from one domain to another.",[71,531,534],{"className":532,"code":533,"language":507},[505],"www.example.com.    IN  CNAME   example.com.\n",[78,535,533],{"__ignoreMap":76},[63,537,539],{"id":538},"mx-record-mail-exchange","MX Record (Mail Exchange)",[11,541,542],{},"Specifies mail servers for the domain.",[71,544,547],{"className":545,"code":546,"language":507},[505],"example.com.    IN  MX  10 mail.example.com.\n",[78,548,546],{"__ignoreMap":76},[11,550,551],{},"The number (10) indicates priority; lower numbers have higher priority.",[63,553,555],{"id":554},"txt-record-text-record","TXT Record (Text Record)",[11,557,558],{},"Stores arbitrary text data, commonly used for SPF, DKIM, and verification.",[71,560,563],{"className":561,"code":562,"language":507},[505],"example.com.    IN  TXT   \"v=spf1 include:_spf.google.com ~all\"\n",[78,564,562],{"__ignoreMap":76},[63,566,568],{"id":567},"ns-record-name-server","NS Record (Name Server)",[11,570,571],{},"Delegates a subdomain to specific name servers.",[71,573,576],{"className":574,"code":575,"language":507},[505],"example.com.    IN  NS   ns1.example.com.\n",[78,577,575],{"__ignoreMap":76},[63,579,581],{"id":580},"soa-record-start-of-authority","SOA Record (Start of Authority)",[11,583,584],{},"Contains administrative information about the zone.",[71,586,589],{"className":587,"code":588,"language":507},[505],"example.com.    IN  SOA   ns1.example.com. admin.example.com. (\n    2023010101 ; Serial\n    3600       ; Refresh\n    1800       ; Retry\n    604800     ; Expire\n    86400      ; Minimum TTL\n)\n",[78,590,588],{"__ignoreMap":76},[63,592,594],{"id":593},"ptr-record-pointer-record","PTR Record (Pointer Record)",[11,596,597],{},"Maps an IP address back to a domain name (reverse DNS).",[71,599,602],{"className":600,"code":601,"language":507},[505],"34.216.184.93.in-addr.arpa.    IN  PTR   example.com.\n",[78,603,601],{"__ignoreMap":76},[11,605,606],{},"These records work together to provide complete domain information and enable various internet services.",[44,608,610],{"id":609},"dns-infrastructure-the-global-network","DNS Infrastructure: The Global Network",[11,612,613],{},"DNS operates through a distributed network of servers working in harmony:",[11,615,616],{},[39,617],{"alt":618,"src":619},"DNS Infrastructure Diagram","\u002Fimages\u002Fblogs\u002Fdns_explained_the_backbone_of_the_world_wide_web\u002Fcomplete-dns-lookup-and-webpage-query.png",[63,621,623],{"id":622},"recursive-resolvers","Recursive Resolvers",[11,625,626],{},"These are the \"middlemen\" of DNS. They accept queries from clients and perform the full resolution process on their behalf. Popular public recursive resolvers include:",[21,628,629,632,635],{},[24,630,631],{},"Google Public DNS (8.8.8.8, 8.8.4.4)",[24,633,634],{},"Cloudflare (1.1.1.1, 1.0.0.1)",[24,636,637],{},"Quad9 (9.9.9.9)",[11,639,640],{},"Recursive resolvers implement aggressive caching to improve performance and reduce load on authoritative servers.",[63,642,644],{"id":643},"authoritative-servers","Authoritative Servers",[11,646,647],{},"These hold the actual zone files and are the definitive source for domain information. They come in two types:",[21,649,650,656],{},[24,651,652,655],{},[149,653,654],{},"Primary (Master):"," Contains the original zone file",[24,657,658,661],{},[149,659,660],{},"Secondary (Slave):"," Replicates data from the primary for redundancy",[11,663,664],{},"Authoritative servers are organized hierarchically and delegate subdomains to other servers.",[63,666,668],{"id":667},"caching-the-performance-booster","Caching: The Performance Booster",[11,670,671],{},"DNS heavily relies on caching at multiple levels:",[21,673,674,680,686,692],{},[24,675,676,679],{},[149,677,678],{},"Browser Cache:"," Short-term storage in the browser",[24,681,682,685],{},[149,683,684],{},"OS Cache:"," System-level DNS cache",[24,687,688,691],{},[149,689,690],{},"Resolver Cache:"," Recursive resolvers cache responses",[24,693,694,697],{},[149,695,696],{},"Authoritative Cache:"," Some authoritative servers implement caching",[11,699,700],{},"TTL (Time To Live) values control how long records are cached. Shorter TTLs provide more current data but increase query volume.",[63,702,704],{"id":703},"anycast-global-distribution","Anycast: Global Distribution",[11,706,707],{},"Many DNS servers use anycast routing, where the same IP address is announced from multiple physical locations worldwide. This ensures queries are routed to the nearest server, reducing latency.",[11,709,710],{},"For example, the root servers are anycasted across hundreds of locations globally, ensuring fast responses from anywhere on earth.",[44,712,714],{"id":713},"dns-security-protecting-the-foundation","DNS Security: Protecting the Foundation",[11,716,717],{},"DNS was designed without security in mind, making it vulnerable to various attacks. Modern solutions address these issues:",[63,719,721],{"id":720},"dnssec-dns-security-extensions","DNSSEC (DNS Security Extensions)",[11,723,724],{},"DNSSEC adds cryptographic signatures to DNS records, ensuring:",[21,726,727,733,739],{},[24,728,729,732],{},[149,730,731],{},"Data Integrity:"," Records haven't been tampered with",[24,734,735,738],{},[149,736,737],{},"Authentication:"," Responses come from legitimate servers",[24,740,741,744],{},[149,742,743],{},"Non-existence Proofs:"," Proves when domains don't exist",[11,746,747],{},"DNSSEC uses a chain of trust from the root down to individual domains. Keys are managed hierarchically, with the root KSK (Key Signing Key) being the ultimate trust anchor.",[63,749,751],{"id":750},"encrypted-dns-protocols","Encrypted DNS Protocols",[11,753,754],{},"Traditional DNS sends queries in plaintext, allowing interception and manipulation.",[21,756,757,763],{},[24,758,759,762],{},[149,760,761],{},"DoT (DNS over TLS):"," Encrypts DNS queries over port 853",[24,764,765,768],{},[149,766,767],{},"DoH (DNS over HTTPS):"," Sends DNS queries over HTTPS (port 443), blending with normal web traffic",[11,770,771],{},"These prevent eavesdropping and make blocking DNS traffic more difficult.",[63,773,775],{"id":774},"common-dns-attacks","Common DNS Attacks",[777,778,780],"h4",{"id":779},"dns-spoofingcache-poisoning","DNS Spoofing\u002FCache Poisoning",[11,782,783],{},"Attackers send fake responses to recursive resolvers, polluting their cache with malicious IP addresses.",[777,785,787],{"id":786},"ddos-amplification","DDoS Amplification",[11,789,790],{},"DNS servers can be used to amplify DDoS attacks since UDP responses can be much larger than queries.",[777,792,794],{"id":793},"dns-tunneling","DNS Tunneling",[11,796,797],{},"Malware uses DNS queries to exfiltrate data by encoding information in domain names.",[777,799,801],{"id":800},"nxdomain-attacks","NXDOMAIN Attacks",[11,803,804],{},"Overloading resolvers with queries for non-existent domains to exhaust resources.",[63,806,808],{"id":807},"mitigation-strategies","Mitigation Strategies",[21,810,811,814,817,820,823],{},[24,812,813],{},"Implement DNSSEC for your domains",[24,815,816],{},"Use encrypted DNS (DoT\u002FDoH) clients",[24,818,819],{},"Deploy DNS firewalls (like Response Policy Zones)",[24,821,822],{},"Monitor for anomalous query patterns",[24,824,825],{},"Use rate limiting on authoritative servers",[44,827,829],{"id":828},"self-hosting-an-authoritative-dns-server-with-powerdns","Self-Hosting an Authoritative DNS Server with PowerDNS",[11,831,832],{},"While managed DNS providers are convenient, self-hosting gives you complete control. PowerDNS is an excellent open-source authoritative DNS server. Let's set it up:",[63,834,836],{"id":835},"installation-with-docker","Installation with Docker",[11,838,839,840,843],{},"Use Docker Compose for easy setup with MySQL backend. Create a ",[78,841,842],{},"docker-compose.yml"," file:",[71,845,849],{"className":846,"code":847,"language":848,"meta":76,"style":76},"language-yaml shiki shiki-themes github-light","version: '3.8'\nservices:\n  mysql:\n    image: mysql:8.0\n    environment:\n      MYSQL_ROOT_PASSWORD: your_mysql_root_password\n      MYSQL_DATABASE: pdns\n      MYSQL_USER: pdns\n      MYSQL_PASSWORD: your_pdns_password\n    volumes:\n      - mysql_data:\u002Fvar\u002Flib\u002Fmysql\n    networks:\n      - pdns\n\n  powerdns:\n    image: pschiffe\u002Fpdns-mysql:latest\n    environment:\n      MYSQL_HOST: mysql\n      MYSQL_PORT: 3306\n      MYSQL_USER: pdns\n      MYSQL_PASS: your_pdns_password\n      MYSQL_DB: pdns\n    ports:\n      - \"53:53\u002Ftcp\"\n      - \"53:53\u002Fudp\"\n      - \"8081:8081\"\n    depends_on:\n      - mysql\n    networks:\n      - pdns\n\nvolumes:\n  mysql_data:\n\nnetworks:\n  pdns:\n","yaml",[78,850,851,864,872,879,889,897,908,919,929,940,948,957,965,972,979,987,997,1004,1015,1026,1035,1045,1055,1063,1071,1079,1087,1095,1102,1109,1116,1121,1129,1137,1142,1150],{"__ignoreMap":76},[81,852,853,857,861],{"class":83,"line":84},[81,854,856],{"class":855},"shJU0","version",[81,858,860],{"class":859},"sgsFI",": ",[81,862,863],{"class":101},"'3.8'\n",[81,865,866,869],{"class":83,"line":95},[81,867,868],{"class":855},"services",[81,870,871],{"class":859},":\n",[81,873,874,877],{"class":83,"line":319},[81,875,876],{"class":855},"  mysql",[81,878,871],{"class":859},[81,880,881,884,886],{"class":83,"line":328},[81,882,883],{"class":855},"    image",[81,885,860],{"class":859},[81,887,888],{"class":101},"mysql:8.0\n",[81,890,892,895],{"class":83,"line":891},5,[81,893,894],{"class":855},"    environment",[81,896,871],{"class":859},[81,898,900,903,905],{"class":83,"line":899},6,[81,901,902],{"class":855},"      MYSQL_ROOT_PASSWORD",[81,904,860],{"class":859},[81,906,907],{"class":101},"your_mysql_root_password\n",[81,909,911,914,916],{"class":83,"line":910},7,[81,912,913],{"class":855},"      MYSQL_DATABASE",[81,915,860],{"class":859},[81,917,918],{"class":101},"pdns\n",[81,920,922,925,927],{"class":83,"line":921},8,[81,923,924],{"class":855},"      MYSQL_USER",[81,926,860],{"class":859},[81,928,918],{"class":101},[81,930,932,935,937],{"class":83,"line":931},9,[81,933,934],{"class":855},"      MYSQL_PASSWORD",[81,936,860],{"class":859},[81,938,939],{"class":101},"your_pdns_password\n",[81,941,943,946],{"class":83,"line":942},10,[81,944,945],{"class":855},"    volumes",[81,947,871],{"class":859},[81,949,951,954],{"class":83,"line":950},11,[81,952,953],{"class":859},"      - ",[81,955,956],{"class":101},"mysql_data:\u002Fvar\u002Flib\u002Fmysql\n",[81,958,960,963],{"class":83,"line":959},12,[81,961,962],{"class":855},"    networks",[81,964,871],{"class":859},[81,966,968,970],{"class":83,"line":967},13,[81,969,953],{"class":859},[81,971,918],{"class":101},[81,973,975],{"class":83,"line":974},14,[81,976,978],{"emptyLinePlaceholder":977},true,"\n",[81,980,982,985],{"class":83,"line":981},15,[81,983,984],{"class":855},"  powerdns",[81,986,871],{"class":859},[81,988,990,992,994],{"class":83,"line":989},16,[81,991,883],{"class":855},[81,993,860],{"class":859},[81,995,996],{"class":101},"pschiffe\u002Fpdns-mysql:latest\n",[81,998,1000,1002],{"class":83,"line":999},17,[81,1001,894],{"class":855},[81,1003,871],{"class":859},[81,1005,1007,1010,1012],{"class":83,"line":1006},18,[81,1008,1009],{"class":855},"      MYSQL_HOST",[81,1011,860],{"class":859},[81,1013,1014],{"class":101},"mysql\n",[81,1016,1018,1021,1023],{"class":83,"line":1017},19,[81,1019,1020],{"class":855},"      MYSQL_PORT",[81,1022,860],{"class":859},[81,1024,1025],{"class":91},"3306\n",[81,1027,1029,1031,1033],{"class":83,"line":1028},20,[81,1030,924],{"class":855},[81,1032,860],{"class":859},[81,1034,918],{"class":101},[81,1036,1038,1041,1043],{"class":83,"line":1037},21,[81,1039,1040],{"class":855},"      MYSQL_PASS",[81,1042,860],{"class":859},[81,1044,939],{"class":101},[81,1046,1048,1051,1053],{"class":83,"line":1047},22,[81,1049,1050],{"class":855},"      MYSQL_DB",[81,1052,860],{"class":859},[81,1054,918],{"class":101},[81,1056,1058,1061],{"class":83,"line":1057},23,[81,1059,1060],{"class":855},"    ports",[81,1062,871],{"class":859},[81,1064,1066,1068],{"class":83,"line":1065},24,[81,1067,953],{"class":859},[81,1069,1070],{"class":101},"\"53:53\u002Ftcp\"\n",[81,1072,1074,1076],{"class":83,"line":1073},25,[81,1075,953],{"class":859},[81,1077,1078],{"class":101},"\"53:53\u002Fudp\"\n",[81,1080,1082,1084],{"class":83,"line":1081},26,[81,1083,953],{"class":859},[81,1085,1086],{"class":101},"\"8081:8081\"\n",[81,1088,1090,1093],{"class":83,"line":1089},27,[81,1091,1092],{"class":855},"    depends_on",[81,1094,871],{"class":859},[81,1096,1098,1100],{"class":83,"line":1097},28,[81,1099,953],{"class":859},[81,1101,1014],{"class":101},[81,1103,1105,1107],{"class":83,"line":1104},29,[81,1106,962],{"class":855},[81,1108,871],{"class":859},[81,1110,1112,1114],{"class":83,"line":1111},30,[81,1113,953],{"class":859},[81,1115,918],{"class":101},[81,1117,1119],{"class":83,"line":1118},31,[81,1120,978],{"emptyLinePlaceholder":977},[81,1122,1124,1127],{"class":83,"line":1123},32,[81,1125,1126],{"class":855},"volumes",[81,1128,871],{"class":859},[81,1130,1132,1135],{"class":83,"line":1131},33,[81,1133,1134],{"class":855},"  mysql_data",[81,1136,871],{"class":859},[81,1138,1140],{"class":83,"line":1139},34,[81,1141,978],{"emptyLinePlaceholder":977},[81,1143,1145,1148],{"class":83,"line":1144},35,[81,1146,1147],{"class":855},"networks",[81,1149,871],{"class":859},[81,1151,1153,1156],{"class":83,"line":1152},36,[81,1154,1155],{"class":855},"  pdns",[81,1157,871],{"class":859},[11,1159,1160],{},"Run the services:",[71,1162,1164],{"className":73,"code":1163,"language":75,"meta":76,"style":76},"docker-compose up -d\n",[78,1165,1166],{"__ignoreMap":76},[81,1167,1168,1171,1174],{"class":83,"line":84},[81,1169,1170],{"class":87},"docker-compose",[81,1172,1173],{"class":101}," up",[81,1175,1176],{"class":91}," -d\n",[63,1178,1180],{"id":1179},"configuration","Configuration",[11,1182,1183,1184,1187],{},"PowerDNS auto-configures with the MySQL backend. Access the web interface at ",[78,1185,1186],{},"http:\u002F\u002Flocalhost:8081",".",[63,1189,1191],{"id":1190},"database-setup","Database Setup",[11,1193,1194],{},"The MySQL database initializes automatically. Create zones via the API or command line:",[71,1196,1198],{"className":73,"code":1197,"language":75,"meta":76,"style":76},"docker-compose exec powerdns pdnsutil create-zone example.com\n",[78,1199,1200],{"__ignoreMap":76},[81,1201,1202,1204,1207,1210,1213,1216],{"class":83,"line":84},[81,1203,1170],{"class":87},[81,1205,1206],{"class":101}," exec",[81,1208,1209],{"class":101}," powerdns",[81,1211,1212],{"class":101}," pdnsutil",[81,1214,1215],{"class":101}," create-zone",[81,1217,1218],{"class":101}," example.com\n",[11,1220,1221],{},"Add some records:",[71,1223,1225],{"className":73,"code":1224,"language":75,"meta":76,"style":76},"sudo pdnsutil add-record example.com @ A 192.168.1.10\nsudo pdnsutil add-record example.com www CNAME example.com\nsudo pdnsutil add-record example.com mail MX \"10 mail.example.com\"\n",[78,1226,1227,1249,1267],{"__ignoreMap":76},[81,1228,1229,1232,1234,1237,1240,1243,1246],{"class":83,"line":84},[81,1230,1231],{"class":87},"sudo",[81,1233,1212],{"class":101},[81,1235,1236],{"class":101}," add-record",[81,1238,1239],{"class":101}," example.com",[81,1241,1242],{"class":101}," @",[81,1244,1245],{"class":101}," A",[81,1247,1248],{"class":91}," 192.168.1.10\n",[81,1250,1251,1253,1255,1257,1259,1262,1265],{"class":83,"line":95},[81,1252,1231],{"class":87},[81,1254,1212],{"class":101},[81,1256,1236],{"class":101},[81,1258,1239],{"class":101},[81,1260,1261],{"class":101}," www",[81,1263,1264],{"class":101}," CNAME",[81,1266,1218],{"class":101},[81,1268,1269,1271,1273,1275,1277,1280,1283],{"class":83,"line":319},[81,1270,1231],{"class":87},[81,1272,1212],{"class":101},[81,1274,1236],{"class":101},[81,1276,1239],{"class":101},[81,1278,1279],{"class":101}," mail",[81,1281,1282],{"class":101}," MX",[81,1284,1285],{"class":101}," \"10 mail.example.com\"\n",[63,1287,1289],{"id":1288},"dnssec-setup","DNSSEC Setup",[11,1291,1292],{},"Enable DNSSEC for the zone:",[71,1294,1296],{"className":73,"code":1295,"language":75,"meta":76,"style":76},"sudo pdnsutil secure-zone example.com\nsudo pdnsutil set-nsec3 example.com\n",[78,1297,1298,1309],{"__ignoreMap":76},[81,1299,1300,1302,1304,1307],{"class":83,"line":84},[81,1301,1231],{"class":87},[81,1303,1212],{"class":101},[81,1305,1306],{"class":101}," secure-zone",[81,1308,1218],{"class":101},[81,1310,1311,1313,1315,1318],{"class":83,"line":95},[81,1312,1231],{"class":87},[81,1314,1212],{"class":101},[81,1316,1317],{"class":101}," set-nsec3",[81,1319,1218],{"class":101},[11,1321,1322],{},"This generates keys and signs the zone automatically.",[63,1324,1326],{"id":1325},"testing","Testing",[11,1328,1329],{},"Test your setup:",[71,1331,1333],{"className":73,"code":1332,"language":75,"meta":76,"style":76},"dig @localhost example.com A\nnslookup example.com localhost\n",[78,1334,1335,1348],{"__ignoreMap":76},[81,1336,1337,1340,1343,1345],{"class":83,"line":84},[81,1338,1339],{"class":87},"dig",[81,1341,1342],{"class":101}," @localhost",[81,1344,1239],{"class":101},[81,1346,1347],{"class":101}," A\n",[81,1349,1350,1353,1355],{"class":83,"line":95},[81,1351,1352],{"class":87},"nslookup",[81,1354,1239],{"class":101},[81,1356,1357],{"class":101}," localhost\n",[63,1359,1361],{"id":1360},"production-considerations","Production Considerations",[21,1363,1364,1367,1370,1373,1376,1379],{},[24,1365,1366],{},"Use MySQL clustering or replication for high availability",[24,1368,1369],{},"Implement monitoring and alerting for both PowerDNS and MySQL",[24,1371,1372],{},"Set up secondary PowerDNS servers for redundancy",[24,1374,1375],{},"Configure proper firewall rules (UDP\u002FTCP port 53)",[24,1377,1378],{},"Implement rate limiting and DDoS protection",[24,1380,1381],{},"Regularly update Docker images and patch PowerDNS",[11,1383,1384],{},"Self-hosting DNS requires careful maintenance but provides maximum control and privacy.",[44,1386,1388],{"id":1387},"dns-troubleshooting-and-best-practices","DNS Troubleshooting and Best Practices",[11,1390,1391],{},"DNS issues can be frustrating but are usually solvable with systematic debugging.",[63,1393,1395],{"id":1394},"common-issues-and-solutions","Common Issues and Solutions",[777,1397,1399],{"id":1398},"slow-resolution","Slow Resolution",[21,1401,1402,1405,1411,1414],{},[24,1403,1404],{},"Check resolver performance",[24,1406,1407,1408],{},"Clear local DNS cache: ",[78,1409,1410],{},"sudo systemd-resolve --flush-caches",[24,1412,1413],{},"Switch to faster public resolvers",[24,1415,1416],{},"Check for network congestion",[777,1418,1420],{"id":1419},"nxdomain-errors","NXDOMAIN Errors",[21,1422,1423,1426,1429,1432],{},[24,1424,1425],{},"Verify domain registration status",[24,1427,1428],{},"Check for typos in domain names",[24,1430,1431],{},"Confirm authoritative servers are responding",[24,1433,1434],{},"Test with different resolvers",[777,1436,1438],{"id":1437},"propagation-delays","Propagation Delays",[11,1440,1441],{},"DNS changes can take 24-48 hours to propagate globally due to caching. Use tools like:",[71,1443,1445],{"className":73,"code":1444,"language":75,"meta":76,"style":76},"dig @8.8.8.8 example.com A\ndig @1.1.1.1 example.com A\n",[78,1446,1447,1458],{"__ignoreMap":76},[81,1448,1449,1451,1454,1456],{"class":83,"line":84},[81,1450,1339],{"class":87},[81,1452,1453],{"class":101}," @8.8.8.8",[81,1455,1239],{"class":101},[81,1457,1347],{"class":101},[81,1459,1460,1462,1465,1467],{"class":83,"line":95},[81,1461,1339],{"class":87},[81,1463,1464],{"class":101}," @1.1.1.1",[81,1466,1239],{"class":101},[81,1468,1347],{"class":101},[777,1470,1472],{"id":1471},"dns-leaks","DNS Leaks",[11,1474,1475],{},"When using VPNs, DNS queries might bypass the tunnel. Test with:",[71,1477,1479],{"className":73,"code":1478,"language":75,"meta":76,"style":76},"nslookup example.com\n",[78,1480,1481],{"__ignoreMap":76},[81,1482,1483,1485],{"class":83,"line":84},[81,1484,1352],{"class":87},[81,1486,1218],{"class":101},[11,1488,1489],{},"Should show VPN resolver IPs, not local ISP.",[63,1491,1493],{"id":1492},"best-practices","Best Practices",[777,1495,1497],{"id":1496},"for-domain-owners","For Domain Owners",[21,1499,1500,1503,1506,1509,1512],{},[24,1501,1502],{},"Use multiple authoritative servers for redundancy",[24,1504,1505],{},"Implement DNSSEC",[24,1507,1508],{},"Set appropriate TTL values (lower for dynamic content)",[24,1510,1511],{},"Monitor DNS performance and availability",[24,1513,1514],{},"Use CDN-integrated DNS for global performance",[777,1516,1518],{"id":1517},"for-developers","For Developers",[21,1520,1521,1524,1527,1530],{},[24,1522,1523],{},"Understand DNS in your application architecture",[24,1525,1526],{},"Implement proper error handling for DNS failures",[24,1528,1529],{},"Use connection pooling to reduce DNS lookups",[24,1531,1532],{},"Consider DNS prefetching in web applications",[777,1534,1536],{"id":1535},"for-system-administrators","For System Administrators",[21,1538,1539,1542,1545,1548,1551],{},[24,1540,1541],{},"Monitor DNS server logs for anomalies",[24,1543,1544],{},"Implement rate limiting to prevent abuse",[24,1546,1547],{},"Keep DNS software updated",[24,1549,1550],{},"Have backup DNS providers ready",[24,1552,1553],{},"Document your DNS configuration thoroughly",[11,1555,1556],{},"DNS reliability is crucial for internet availability. Regular monitoring and proactive maintenance prevent most issues.",[44,1558,1560],{"id":1559},"learning-resources","Learning Resources",[21,1562,1563,1572,1579,1586,1593,1600,1607],{},[24,1564,1565],{},[1566,1567,1571],"a",{"href":1568,"rel":1569},"https:\u002F\u002Ftools.ietf.org\u002Fhtml\u002Frfc1035",[1570],"nofollow","RFC 1035 - Domain Names - Implementation and Specification",[24,1573,1574],{},[1566,1575,1578],{"href":1576,"rel":1577},"https:\u002F\u002Fwww.icann.org\u002Fdnssec",[1570],"DNSSEC Practice Statement",[24,1580,1581],{},[1566,1582,1585],{"href":1583,"rel":1584},"https:\u002F\u002Fdoc.powerdns.com\u002F",[1570],"PowerDNS Documentation",[24,1587,1588],{},[1566,1589,1592],{"href":1590,"rel":1591},"https:\u002F\u002Fwww.cloudflare.com\u002Flearning\u002Fdns\u002F",[1570],"Cloudflare Learning Center - DNS",[24,1594,1595],{},[1566,1596,1599],{"href":1597,"rel":1598},"https:\u002F\u002Fdnsmadeeasy.com\u002Fsupport\u002Fdns-glossary\u002F",[1570],"DNS Made Easy - DNS Glossary",[24,1601,1602],{},[1566,1603,1606],{"href":1604,"rel":1605},"https:\u002F\u002Fwww.nlnetlabs.nl\u002Fprojects\u002Fldns\u002F",[1570],"Practical DNSSEC",[24,1608,1609],{},[1566,1610,1613],{"href":1611,"rel":1612},"https:\u002F\u002Ftools.ietf.org\u002Fhtml\u002Frfc8484",[1570],"DNS over HTTPS (DoH) RFC 8484",[44,1615,1617],{"id":1616},"conclusion","Conclusion",[11,1619,1620],{},"DNS is the unsung hero of the internet, silently translating human-readable names into machine-routable addresses billions of times per day. Its distributed, hierarchical design has proven remarkably resilient, scaling from a handful of hosts to billions of connected devices.",[11,1622,1623],{},"Understanding DNS goes beyond technical curiosity—it's essential for anyone working with internet technologies. Whether you're a developer troubleshooting connectivity issues, a system administrator designing resilient infrastructure, or simply a user wanting to understand how the web works, DNS knowledge is fundamental.",[11,1625,1626],{},"As the internet evolves with new protocols like DNS over HTTPS and DNSSEC adoption grows, DNS continues to adapt while maintaining its core principles of decentralization and reliability. The next time you type a URL into your browser, remember the complex, global infrastructure that makes it all possible.",[11,1628,1629],{},"DNS truly is the backbone of the World Wide Web.",[1631,1632,1633],"style",{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .shJU0, html code.shiki .shJU0{--shiki-default:#22863A}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}",{"title":76,"searchDepth":95,"depth":95,"links":1635},[1636,1642,1647,1655,1665,1671,1677,1685,1689,1690],{"id":46,"depth":95,"text":47,"children":1637},[1638,1639,1640,1641],{"id":65,"depth":319,"text":66},{"id":166,"depth":319,"text":167},{"id":249,"depth":319,"text":250},{"id":291,"depth":319,"text":292},{"id":355,"depth":95,"text":356,"children":1643},[1644,1645,1646],{"id":362,"depth":319,"text":363},{"id":372,"depth":319,"text":373},{"id":402,"depth":319,"text":403},{"id":423,"depth":95,"text":424,"children":1648},[1649,1650,1651,1652,1653,1654],{"id":430,"depth":319,"text":431},{"id":437,"depth":319,"text":438},{"id":444,"depth":319,"text":445},{"id":454,"depth":319,"text":455},{"id":464,"depth":319,"text":465},{"id":474,"depth":319,"text":475},{"id":490,"depth":95,"text":491,"children":1656},[1657,1658,1659,1660,1661,1662,1663,1664],{"id":497,"depth":319,"text":498},{"id":512,"depth":319,"text":513},{"id":525,"depth":319,"text":526},{"id":538,"depth":319,"text":539},{"id":554,"depth":319,"text":555},{"id":567,"depth":319,"text":568},{"id":580,"depth":319,"text":581},{"id":593,"depth":319,"text":594},{"id":609,"depth":95,"text":610,"children":1666},[1667,1668,1669,1670],{"id":622,"depth":319,"text":623},{"id":643,"depth":319,"text":644},{"id":667,"depth":319,"text":668},{"id":703,"depth":319,"text":704},{"id":713,"depth":95,"text":714,"children":1672},[1673,1674,1675,1676],{"id":720,"depth":319,"text":721},{"id":750,"depth":319,"text":751},{"id":774,"depth":319,"text":775},{"id":807,"depth":319,"text":808},{"id":828,"depth":95,"text":829,"children":1678},[1679,1680,1681,1682,1683,1684],{"id":835,"depth":319,"text":836},{"id":1179,"depth":319,"text":1180},{"id":1190,"depth":319,"text":1191},{"id":1288,"depth":319,"text":1289},{"id":1325,"depth":319,"text":1326},{"id":1360,"depth":319,"text":1361},{"id":1387,"depth":95,"text":1388,"children":1686},[1687,1688],{"id":1394,"depth":319,"text":1395},{"id":1492,"depth":319,"text":1493},{"id":1559,"depth":95,"text":1560},{"id":1616,"depth":95,"text":1617},"2026-01-13","How DNS works at a global scale, real-world DNS architecture, and a walkthrough of self-hosting an authoritative DNS server with PowerDNS.",false,"md",{},"\u002Fblogs\u002Fdns_explained_the_backbone_of_the_world_wide_web",{"title":6,"description":1692},"blogs\u002Fdns_explained_the_backbone_of_the_world_wide_web\u002Findex",[1700,1701,1702,1703,1704,1705],"DNS","Networking","Infrastructure","PowerDNS","Self-hosting","Internet Protocols","pgiSwRqY8V4zd_XGWgti2-CEotu0Dv8TIDVw5nQR1c8",{"id":1708,"title":1709,"body":1710,"date":2954,"description":2955,"draft":1693,"extension":1694,"image":1727,"meta":2956,"navigation":977,"path":2957,"seo":2958,"stem":2959,"tags":2960,"__hash__":2964},"blogs\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Findex.md","What is a web server and role of nginx in it ?",{"type":8,"value":1711,"toc":2936},[1712,1716,1719,1722,1728,1732,1735,1749,1752,1755,1759,1762,1770,1773,1781,1784,1787,1807,1810,1814,1817,1820,1823,1829,1835,1838,1841,1844,1850,1853,1856,1860,1863,1866,1873,1879,1882,1885,1893,1896,1900,1903,1906,1912,1915,1918,1921,1924,1927,1930,1933,1936,1940,1943,1951,1956,1959,1963,1966,1969,1972,1975,1978,1981,1987,1990,1993,1997,2000,2003,2006,2009,2012,2017,2020,2024,2032,2035,2066,2069,2078,2080,2083,2093,2103,2134,2137,2153,2156,2160,2163,2177,2184,2190,2281,2288,2292,2295,2304,2307,2346,2352,2504,2508,2599,2602,2609,2655,2665,2676,2680,2683,2686,2710,2716,2809,2811,2815,2852,2855,2867,2869,2872,2879,2882,2900,2903,2906,2910,2933],[44,1713,1715],{"id":1714},"introduction","Introduction",[11,1717,1718],{},"The World Wide Web (WWW) was invented in 1989 by Tim Berners-Lee, but it wasn’t until 1991 that it became publicly available. Since then, the internet has evolved dramatically, with billions of users accessing websites daily. At the core of this communication lies the web server a foundational component that delivers content from a server to a user's browser.",[11,1720,1721],{},"Among the most popular web servers today is Nginx (pronounced engine-x), known for its high performance, scalability, and efficiency.",[11,1723,1724],{},[39,1725],{"alt":1726,"src":1727},"Nginx","\u002Fimages\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Fnginx.png",[44,1729,1731],{"id":1730},"the-problem-it-solves","The problem it solves",[11,1733,1734],{},"Imagine writing a custom web server from scratch every time you build an application. You’d need to handle:",[339,1736,1737,1740,1743,1746],{},[24,1738,1739],{},"Networking (managing TCP connections, sockets, etc.)",[24,1741,1742],{},"HTTP protocol compliance (handling GET, POST, headers, caching)",[24,1744,1745],{},"Concurrency (serving thousands of clients at once)",[24,1747,1748],{},"Security (TLS\u002FSSL, request limits, filtering)",[11,1750,1751],{},"That’s a lot of work for something every developer needs.",[11,1753,1754],{},"Nginx solves this by providing reusable web server that works across programming languages and frameworks. Instead of reinventing the wheel, developers can let Nginx handle the web traffic while their application focuses on business logic.",[44,1756,1758],{"id":1757},"architecture","Architecture",[11,1760,1761],{},"At its core, Nginx follows a client-server model:",[21,1763,1764,1767],{},[24,1765,1766],{},"A client (Browser, API consumer, Mobile app) sends an HTTP request.",[24,1768,1769],{},"The server (Nginx) processes that request and sends a response.",[11,1771,1772],{},"Default Ports by convention on which all web servers listen:",[21,1774,1775,1778],{},[24,1776,1777],{},"Port 80 → HTTP",[24,1779,1780],{},"Port 443 → HTTPS (with SSL\u002FTLS)",[11,1782,1783],{},"NGINX acts as an intermediary between the client and the web services. It handles the client requests and routes it to the backend web service. It is also known as a reverse proxy and can load balance the request among multiple backend servers.",[11,1785,1786],{},"While NGINX solves most of the problems with traditional web service architecture, it still needs to solve:",[339,1788,1789,1795,1801],{},[24,1790,1791,1794],{},[149,1792,1793],{},"Concurrent connections"," - Large number of concurrent connections from clients.",[24,1796,1797,1800],{},[149,1798,1799],{},"Performance"," - No performance degradation with user growth.",[24,1802,1803,1806],{},[149,1804,1805],{},"Efficient resource utilization"," - Low memory usage and optimal CPU utilization.",[11,1808,1809],{},"Before diving into the solution, let’s revisit connection management basics and understand the scalability bottlenecks.",[63,1811,1813],{"id":1812},"how-are-the-connections-handled","How are the connections handled ?",[11,1815,1816],{},"When a web server starts, it calls the operating System and passes the port on which it listens. For e.g., Web servers would pass port 80 (http) or 443 (https) to listen.",[11,1818,1819],{},"When the client connects, the OS’s kernel stack performs a TCP handshake and establishes a connection. The OS assigns a file descriptor or a socket for each connection.",[11,1821,1822],{},"The below diagram shows the connection establishment between the client and the server:",[11,1824,1825],{},[39,1826],{"alt":1827,"src":1828},"client-connection","\u002Fimages\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Fclient-connection.png",[11,1830,1831,1834],{},[149,1832,1833],{},"Note:"," NIC stands for Network interface card",[11,1836,1837],{},"By default, sending and receiving data over a network (Network I\u002FO) is blocking. A thread or a process goes into waiting state while writing or reading data to\u002Ffrom the network.",[11,1839,1840],{},"Also, the network I\u002FO is dependent on the client’s bandwidth. Data transfer may take a long time for slow clients.",[11,1842,1843],{},"The following diagram shows how a process waits until the complete data transfer:",[11,1845,1846],{},[39,1847],{"alt":1848,"src":1849},"data-transfer","\u002Fimages\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Fdata-transfer.png",[11,1851,1852],{},"As a result, the server can’t accept new connections if it’s already processing request from a client. This hinders the system’s scalability and performance both.",[11,1854,1855],{},"There are several ways to tackle this problem and handle more connections. Let’s understand the different approaches and their limitations.",[63,1857,1859],{"id":1858},"process-per-request-approach","Process-Per-Request Approach",[11,1861,1862],{},"To overcome the network I\u002FO bottleneck, the process can fork a new child process. The child process would then handle a new client connection.",[11,1864,1865],{},"Every connection would correspond to a new child process. Once the request\u002Fresponse cycle is completed, the child process would be killed.",[11,1867,1868,1869],{},"The below diagram illustrates this process:\n",[39,1870],{"alt":1871,"src":1872},"process-per-request","\u002Fimages\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Fprocess-per-request.png",[1874,1875,1876],"blockquote",{},[11,1877,1878],{},"Do you think this approach would scale to millions of users\u002Fconnections ? Take a moment to think and then continue reading",[11,1880,1881],{},"Let’s assume the server RAM size is 32 GB and each process takes 100 MB. So, then it can handle only 320 (32 GB\u002F 100 MB) connections in the best case.",[11,1883,1884],{},"Here are some downsides of this approach:",[21,1886,1887,1890],{},[24,1888,1889],{},"Scalability Issues - Number of connections depend on the hardware (RAM size). More connections would lead to out of memory issues.",[24,1891,1892],{},"Performance Issues - Forking a child process is slow and would impact the performance.",[11,1894,1895],{},"Can we do better ?  What if instead of forking a process, we launch a thread ? Let’s explore this approach in the next section.",[63,1897,1899],{"id":1898},"thread-per-request-approach","Thread-Per-Request Approach",[11,1901,1902],{},"In this approach, a thread is launched every time a client connection is established. Each request is handled independently by a different thread.",[11,1904,1905],{},"The below diagram shows how this model works:",[11,1907,1908],{},[39,1909],{"alt":1910,"src":1911},"thread-per-request","\u002Fimages\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Fthread-per-request.png",[11,1913,1914],{},"Threads are lightweight and almost 1\u002F10th size of a process. As a result, this is a significant improvement from the Process-Per-Request approach.",[11,1916,1917],{},"While this approach can handle more number of connections, it would still run into issues highlighted in the previous section.",[11,1919,1920],{},"A process can’t launch an infinite number of threads. The benefits of multi-threading diminish with large number of threads due to frequent CPU context switching.",[11,1922,1923],{},"We can still improve by using a thread pool and launching a fixed number of threads. For eg:- 500 threads in the process.",[11,1925,1926],{},"This improvement would result in efficient memory usage. However, if all the threads are busy, the new connections would wait in the request queue resulting in slowness.",[11,1928,1929],{},"Hence, this approach also doesn’t solve for scalability and performance. We can’t scale since the primary bottleneck is the time-consuming network I\u002FO.",[11,1931,1932],{},"Is there a way to unblock the process or thread during the network I\u002FO ? Yes, and NGINX employs an intelligent tactic using its event-driven non-blocking I\u002FO.",[11,1934,1935],{},"Let’s understand NGINX’s architecture in detail in the next section.",[63,1937,1939],{"id":1938},"nginx-architecture","NGINX Architecture",[11,1941,1942],{},"NGINX uses a modular architecture and consists of several components such as:",[339,1944,1945,1948],{},[24,1946,1947],{},"Master process - It acts as the central controller and is responsible for starting, stopping, and launching the worker processes.",[24,1949,1950],{},"Worker processes - These run the core NGINX logic and are responsible for connection handling, request forwarding, load balancing, etc.",[11,1952,1953],{},[39,1954],{"alt":1938,"src":1955},"\u002Fimages\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Fnginx-architecture.png",[11,1957,1958],{},"Let’s now dive into the details of how NGINX can scale to million concurrent connections.",[777,1960,1962],{"id":1961},"event-driven-non-blocking-io","Event-driven Non-blocking I\u002FO",[11,1964,1965],{},"In case of non-blocking I\u002FO, the web server or the application doesn’t wait for the client’s data. Instead, the OS informs the application once the data is available.",[11,1967,1968],{},"This makes the process event-driven. Whenever the client’s data is available, the application would get interrupted and it would process the data. Otherwise, it would continue to do something else.",[11,1970,1971],{},"Further, the application doesn’t go into a waiting state. It can execute other tasks and efficiently utilize the CPU.",[11,1973,1974],{},"Internally, the application uses a system call called epoll or kqueue and then registers the sockets. The operating system uses a kernel data structure (Epoll instance) to keep track of the sockets that an application is interested in.",[11,1976,1977],{},"Once data is available in a subset of sockets, those sockets are moved into a ready list. The OS then informs the application about those sockets. Finally, the application then processes the data.",[11,1979,1980],{},"The below diagram illustrates this flow:",[11,1982,1983],{},[39,1984],{"alt":1985,"src":1986},"event-driven-io","\u002Fimages\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Fevent-driven-io.png",[11,1988,1989],{},"As seen from the above diagram, once data becomes available on fd3, and fd4, the process is notified by the OS.",[11,1991,1992],{},"Let’s now understand this in the context of a NGINX worker.",[777,1994,1996],{"id":1995},"nginx-worker","Nginx worker",[11,1998,1999],{},"Each NGINX worker is single-threaded and it runs an event loop. The event loop works like a while loop and checks for any activity on the socket or new connections.",[11,2001,2002],{},"With non-blocking sockets, the worker doesn’t need to wait till the data is completely sent to the client. It can quickly move onto the next connection and process the request.",[11,2004,2005],{},"Since network I\u002FO is non-blocking, the process doesn’t wait for the data transfer. And the worker uses CPU only for request parsing, filtering and other compute operations.",[11,2007,2008],{},"Compute operations are less time-taking (in order of micro-seconds). As a result, a single worker can process 100K requests every second concurrently.",[11,2010,2011],{},"Assuming that a single worker can handle 100K connections, if it’s a 10-core CPU, the server can handle 1 million concurrent connections. (Example for illustration only, in real world, things might be different).",[1874,2013,2014],{},[11,2015,2016],{},"Note: A server must have sufficient memory to serve 1 million connections since each connection needs 100KB-1MB memory. But the OS kernel can be tuned to reduce the connection’s memory.(there are trade-offs to this approach)",[11,2018,2019],{},"The event-driven non-blocking I\u002FO efficiently utilizes the CPU and doesn’t consume memory like Process-Per-Request or Thread-Per-Request approach.",[44,2021,2023],{"id":2022},"installation","Installation",[11,2025,2026,2027],{},"Prerequisite: ",[1566,2028,2031],{"href":2029,"rel":2030},"https:\u002F\u002F9ovind.in\u002Fblogs\u002Fvirtualization_containers_and_role_of_docker_in_it\u002F#docker-installation-on-linux",[1570],"Docker",[11,2033,2034],{},"One of the simplest ways to install and run Nginx today is via Docker:",[71,2036,2038],{"className":73,"code":2037,"language":75,"meta":76,"style":76},"docker run --rm --name web_server -p 80:80 nginx\n",[78,2039,2040],{"__ignoreMap":76},[81,2041,2042,2045,2048,2051,2054,2057,2060,2063],{"class":83,"line":84},[81,2043,2044],{"class":87},"docker",[81,2046,2047],{"class":101}," run",[81,2049,2050],{"class":91}," --rm",[81,2052,2053],{"class":91}," --name",[81,2055,2056],{"class":101}," web_server",[81,2058,2059],{"class":91}," -p",[81,2061,2062],{"class":101}," 80:80",[81,2064,2065],{"class":101}," nginx\n",[11,2067,2068],{},"This pulls the latest Nginx image and starts a container listening on port 80.",[11,2070,2071,2072,2077],{},"Visit ",[1566,2073,2076],{"href":2074,"rel":2075},"http:\u002F\u002Flocalhost",[1570],"localhost"," in your Browser and you will see a nginx welcome page.",[44,2079,1180],{"id":1179},[11,2081,2082],{},"Nginx has one master process and several worker processes. The main purpose of the master process is to read and evaluate configuration, and maintain worker processes. Worker processes do actual processing of requests.",[11,2084,2085,2086,2089,2090,1187],{},"The way nginx and its modules work is determined in the configuration file. By default, the configuration file is named ",[78,2087,2088],{},"nginx.conf"," and placed in the directory ",[78,2091,2092],{},"\u002Fetc\u002Fnginx",[11,2094,2095,2096,2098,2099,2102],{},"To view the default configuration file ",[78,2097,2088],{},", you first need to exec into ",[78,2100,2101],{},"web_server"," container.",[71,2104,2106],{"className":73,"code":2105,"language":75,"meta":76,"style":76},"docker exec -it web_server bash\n\ncat \u002Fetc\u002Fnginx\u002Fnginx.conf\n",[78,2107,2108,2122,2126],{"__ignoreMap":76},[81,2109,2110,2112,2114,2117,2119],{"class":83,"line":84},[81,2111,2044],{"class":87},[81,2113,1206],{"class":101},[81,2115,2116],{"class":91}," -it",[81,2118,2056],{"class":101},[81,2120,2121],{"class":101}," bash\n",[81,2123,2124],{"class":83,"line":95},[81,2125,978],{"emptyLinePlaceholder":977},[81,2127,2128,2131],{"class":83,"line":319},[81,2129,2130],{"class":87},"cat",[81,2132,2133],{"class":101}," \u002Fetc\u002Fnginx\u002Fnginx.conf\n",[11,2135,2136],{},"Changes made in the configuration file will not be applied until the command to reload configuration is sent to nginx or it is restarted. To reload configuration, execute:",[71,2138,2140],{"className":73,"code":2139,"language":75,"meta":76,"style":76},"nginx -s reload\n",[78,2141,2142],{"__ignoreMap":76},[81,2143,2144,2147,2150],{"class":83,"line":84},[81,2145,2146],{"class":87},"nginx",[81,2148,2149],{"class":91}," -s",[81,2151,2152],{"class":101}," reload\n",[11,2154,2155],{},"Once the master process receives the signal to reload configuration, it checks the syntax validity of the new configuration file and tries to apply the configuration provided in it. If this is a success, the master process starts new worker processes and sends messages to old worker processes, requesting them to shut down. Otherwise, the master process rolls back the changes and continues to work with the old configuration. Old worker processes, receiving a command to shut down, stop accepting new connections and continue to service current requests until all such requests are serviced. After that, the old worker processes exit.",[63,2157,2159],{"id":2158},"configuration-file-structure","Configuration file structure",[11,2161,2162],{},"nginx consists of modules which are controlled by directives specified in the configuration file.\nDirectives are divided into:",[339,2164,2165,2171],{},[24,2166,2167,2170],{},[149,2168,2169],{},"Simple directives"," consists of the name and parameters separated by spaces and ends with a semicolon (;)",[24,2172,2173,2176],{},[149,2174,2175],{},"Block directives"," has the same structure as a simple directive, but instead of the semicolon it ends with a set of additional instructions surrounded by braces ({ and }).",[11,2178,2179,2180,2183],{},"If a block directive can have other directives inside braces, it is called a ",[149,2181,2182],{},"context",". Eg: events, http, server and location.",[11,2185,2186,2187,1187],{},"Directives placed in the configuration file outside of any contexts are considered to be in the ",[149,2188,2189],{},"main context",[71,2191,2195],{"className":2192,"code":2193,"language":2194,"meta":76,"style":76},"language-conf shiki shiki-themes github-light","# nginx.conf is the main context\n\n# simple directives\nuser nginx;\nworker_processes auto;\n\n# block directives\nevents {\n\n}\n\nhttp {\n    server {\n        location {\n\n        }\n    }\n}\n","conf",[78,2196,2197,2202,2206,2211,2216,2221,2225,2230,2235,2239,2244,2248,2253,2258,2263,2267,2272,2277],{"__ignoreMap":76},[81,2198,2199],{"class":83,"line":84},[81,2200,2201],{},"# nginx.conf is the main context\n",[81,2203,2204],{"class":83,"line":95},[81,2205,978],{"emptyLinePlaceholder":977},[81,2207,2208],{"class":83,"line":319},[81,2209,2210],{},"# simple directives\n",[81,2212,2213],{"class":83,"line":328},[81,2214,2215],{},"user nginx;\n",[81,2217,2218],{"class":83,"line":891},[81,2219,2220],{},"worker_processes auto;\n",[81,2222,2223],{"class":83,"line":899},[81,2224,978],{"emptyLinePlaceholder":977},[81,2226,2227],{"class":83,"line":910},[81,2228,2229],{},"# block directives\n",[81,2231,2232],{"class":83,"line":921},[81,2233,2234],{},"events {\n",[81,2236,2237],{"class":83,"line":931},[81,2238,978],{"emptyLinePlaceholder":977},[81,2240,2241],{"class":83,"line":942},[81,2242,2243],{},"}\n",[81,2245,2246],{"class":83,"line":950},[81,2247,978],{"emptyLinePlaceholder":977},[81,2249,2250],{"class":83,"line":959},[81,2251,2252],{},"http {\n",[81,2254,2255],{"class":83,"line":967},[81,2256,2257],{},"    server {\n",[81,2259,2260],{"class":83,"line":974},[81,2261,2262],{},"        location {\n",[81,2264,2265],{"class":83,"line":981},[81,2266,978],{"emptyLinePlaceholder":977},[81,2268,2269],{"class":83,"line":989},[81,2270,2271],{},"        }\n",[81,2273,2274],{"class":83,"line":999},[81,2275,2276],{},"    }\n",[81,2278,2279],{"class":83,"line":1006},[81,2280,2243],{},[11,2282,2283,2284,2287],{},"The rest of a line after the ",[78,2285,2286],{},"#"," sign is considered a comment.",[44,2289,2291],{"id":2290},"serving-static-content","Serving static content",[11,2293,2294],{},"An important web server task is serving out files (such as images or static HTML pages).",[11,2296,2297,2298,2301,2302,1187],{},"We will implement an example where files will be served from local directory: ",[78,2299,2300],{},"\u002Fvar\u002Fwww"," (which may contain HTML files and images). This will require editing of the configuration file ",[78,2303,2088],{},[11,2305,2306],{},"Create this file structure",[71,2308,2310],{"className":73,"code":2309,"language":75,"meta":76,"style":76},"nginx_example\u002F\n├── nginx.conf\n└── web_pages\n    └── index.html\n    └── image.png\n",[78,2311,2312,2317,2325,2332,2339],{"__ignoreMap":76},[81,2313,2314],{"class":83,"line":84},[81,2315,2316],{"class":87},"nginx_example\u002F\n",[81,2318,2319,2322],{"class":83,"line":95},[81,2320,2321],{"class":87},"├──",[81,2323,2324],{"class":101}," nginx.conf\n",[81,2326,2327,2329],{"class":83,"line":319},[81,2328,313],{"class":87},[81,2330,2331],{"class":101}," web_pages\n",[81,2333,2334,2336],{"class":83,"line":328},[81,2335,322],{"class":87},[81,2337,2338],{"class":101}," index.html\n",[81,2340,2341,2343],{"class":83,"line":891},[81,2342,322],{"class":87},[81,2344,2345],{"class":101}," image.png\n",[11,2347,2348,2349],{},"Put below content in ",[78,2350,2351],{},"index.html",[71,2353,2357],{"className":2354,"code":2355,"language":2356,"meta":76,"style":76},"language-html shiki shiki-themes github-light","\u003C!DOCTYPE html>\n\u003Chtml lang=\"en\">\n\u003Chead>\n    \u003Cmeta charset=\"UTF-8\">\n    \u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    \u003Ctitle>Document\u003C\u002Ftitle>\n\u003C\u002Fhead>\n\u003Cbody>\n    \u003Ch1>Hello world from Nginx container\u003C\u002Fh1>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n","html",[78,2358,2359,2373,2391,2400,2418,2442,2456,2465,2474,2488,2496],{"__ignoreMap":76},[81,2360,2361,2364,2367,2370],{"class":83,"line":84},[81,2362,2363],{"class":859},"\u003C!",[81,2365,2366],{"class":855},"DOCTYPE",[81,2368,2369],{"class":87}," html",[81,2371,2372],{"class":859},">\n",[81,2374,2375,2378,2380,2383,2386,2389],{"class":83,"line":95},[81,2376,2377],{"class":859},"\u003C",[81,2379,2356],{"class":855},[81,2381,2382],{"class":87}," lang",[81,2384,2385],{"class":859},"=",[81,2387,2388],{"class":101},"\"en\"",[81,2390,2372],{"class":859},[81,2392,2393,2395,2398],{"class":83,"line":319},[81,2394,2377],{"class":859},[81,2396,2397],{"class":855},"head",[81,2399,2372],{"class":859},[81,2401,2402,2405,2408,2411,2413,2416],{"class":83,"line":328},[81,2403,2404],{"class":859},"    \u003C",[81,2406,2407],{"class":855},"meta",[81,2409,2410],{"class":87}," charset",[81,2412,2385],{"class":859},[81,2414,2415],{"class":101},"\"UTF-8\"",[81,2417,2372],{"class":859},[81,2419,2420,2422,2424,2427,2429,2432,2435,2437,2440],{"class":83,"line":891},[81,2421,2404],{"class":859},[81,2423,2407],{"class":855},[81,2425,2426],{"class":87}," name",[81,2428,2385],{"class":859},[81,2430,2431],{"class":101},"\"viewport\"",[81,2433,2434],{"class":87}," content",[81,2436,2385],{"class":859},[81,2438,2439],{"class":101},"\"width=device-width, initial-scale=1.0\"",[81,2441,2372],{"class":859},[81,2443,2444,2446,2449,2452,2454],{"class":83,"line":899},[81,2445,2404],{"class":859},[81,2447,2448],{"class":855},"title",[81,2450,2451],{"class":859},">Document\u003C\u002F",[81,2453,2448],{"class":855},[81,2455,2372],{"class":859},[81,2457,2458,2461,2463],{"class":83,"line":910},[81,2459,2460],{"class":859},"\u003C\u002F",[81,2462,2397],{"class":855},[81,2464,2372],{"class":859},[81,2466,2467,2469,2472],{"class":83,"line":921},[81,2468,2377],{"class":859},[81,2470,2471],{"class":855},"body",[81,2473,2372],{"class":859},[81,2475,2476,2478,2481,2484,2486],{"class":83,"line":931},[81,2477,2404],{"class":859},[81,2479,2480],{"class":855},"h1",[81,2482,2483],{"class":859},">Hello world from Nginx container\u003C\u002F",[81,2485,2480],{"class":855},[81,2487,2372],{"class":859},[81,2489,2490,2492,2494],{"class":83,"line":942},[81,2491,2460],{"class":859},[81,2493,2471],{"class":855},[81,2495,2372],{"class":859},[81,2497,2498,2500,2502],{"class":83,"line":950},[81,2499,2460],{"class":859},[81,2501,2356],{"class":855},[81,2503,2372],{"class":859},[11,2505,2348,2506],{},[78,2507,2088],{},[71,2509,2511],{"className":2192,"code":2510,"language":2194,"meta":76,"style":76},"user nginx;\nworker_processes auto;\n\nevents {\n\n}\n\nhttp {\n    server {\n        listen 80;\n        server_name _;\n\n        root \u002Fvar\u002Fwww;\n        index index.html index.htm;\n\n        location \u002F {\n            try_files $uri $uri\u002F =404;\n        }\n    }\n}\n",[78,2512,2513,2517,2521,2525,2529,2533,2537,2541,2545,2549,2554,2559,2563,2568,2573,2577,2582,2587,2591,2595],{"__ignoreMap":76},[81,2514,2515],{"class":83,"line":84},[81,2516,2215],{},[81,2518,2519],{"class":83,"line":95},[81,2520,2220],{},[81,2522,2523],{"class":83,"line":319},[81,2524,978],{"emptyLinePlaceholder":977},[81,2526,2527],{"class":83,"line":328},[81,2528,2234],{},[81,2530,2531],{"class":83,"line":891},[81,2532,978],{"emptyLinePlaceholder":977},[81,2534,2535],{"class":83,"line":899},[81,2536,2243],{},[81,2538,2539],{"class":83,"line":910},[81,2540,978],{"emptyLinePlaceholder":977},[81,2542,2543],{"class":83,"line":921},[81,2544,2252],{},[81,2546,2547],{"class":83,"line":931},[81,2548,2257],{},[81,2550,2551],{"class":83,"line":942},[81,2552,2553],{},"        listen 80;\n",[81,2555,2556],{"class":83,"line":950},[81,2557,2558],{},"        server_name _;\n",[81,2560,2561],{"class":83,"line":959},[81,2562,978],{"emptyLinePlaceholder":977},[81,2564,2565],{"class":83,"line":967},[81,2566,2567],{},"        root \u002Fvar\u002Fwww;\n",[81,2569,2570],{"class":83,"line":974},[81,2571,2572],{},"        index index.html index.htm;\n",[81,2574,2575],{"class":83,"line":981},[81,2576,978],{"emptyLinePlaceholder":977},[81,2578,2579],{"class":83,"line":989},[81,2580,2581],{},"        location \u002F {\n",[81,2583,2584],{"class":83,"line":999},[81,2585,2586],{},"            try_files $uri $uri\u002F =404;\n",[81,2588,2589],{"class":83,"line":1006},[81,2590,2271],{},[81,2592,2593],{"class":83,"line":1017},[81,2594,2276],{},[81,2596,2597],{"class":83,"line":1028},[81,2598,2243],{},[11,2600,2601],{},"Now let's stop our previous nginx container and run new one with new configurations.",[11,2603,2604,2605,2608],{},"But before running below command please make sure you are in ",[78,2606,2607],{},"nginx_example"," folder.",[71,2610,2612],{"className":73,"code":2611,"language":75,"meta":76,"style":76},"cd nginx_example\n\ndocker run --rm --name web_server -p 80:80 -v .\u002Fweb_pages:\u002Fvar\u002Fwww -v .\u002Fnginx.conf:\u002Fetc\u002Fnginx\u002Fnginx.conf nginx\n",[78,2613,2614,2622,2626],{"__ignoreMap":76},[81,2615,2616,2619],{"class":83,"line":84},[81,2617,2618],{"class":91},"cd",[81,2620,2621],{"class":101}," nginx_example\n",[81,2623,2624],{"class":83,"line":95},[81,2625,978],{"emptyLinePlaceholder":977},[81,2627,2628,2630,2632,2634,2636,2638,2640,2642,2645,2648,2650,2653],{"class":83,"line":319},[81,2629,2044],{"class":87},[81,2631,2047],{"class":101},[81,2633,2050],{"class":91},[81,2635,2053],{"class":91},[81,2637,2056],{"class":101},[81,2639,2059],{"class":91},[81,2641,2062],{"class":101},[81,2643,2644],{"class":91}," -v",[81,2646,2647],{"class":101}," .\u002Fweb_pages:\u002Fvar\u002Fwww",[81,2649,2644],{"class":91},[81,2651,2652],{"class":101}," .\u002Fnginx.conf:\u002Fetc\u002Fnginx\u002Fnginx.conf",[81,2654,2065],{"class":101},[11,2656,2071,2657,2660,2661],{},[1566,2658,2074],{"href":2074,"rel":2659},[1570]," in your Browser and you will see this page\n",[39,2662],{"alt":2663,"src":2664},"nginx-hello-world","\u002Fimages\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Fnginx-hello-world.png",[11,2666,2667,2668,2671,2672],{},"You can also view image file you have put in ",[78,2669,2670],{},"web_pages"," folder by visiting ",[1566,2673,2674],{"href":2674,"rel":2675},"http:\u002F\u002Flocalhost\u002Fimage.png",[1570],[44,2677,2679],{"id":2678},"reverse-proxy","Reverse proxy",[11,2681,2682],{},"One of the frequent uses of nginx is setting it up as a proxy server, which means a server that receives requests, passes them to the proxied servers, retrieves responses from them, and sends them to the clients.",[11,2684,2685],{},"We will configure a basic proxy server, which servers requests of other websites with our custom url like:",[339,2687,2688,2700],{},[24,2689,2690,2694,2695,2699],{},[1566,2691,2692],{"href":2692,"rel":2693},"http:\u002F\u002Flocalhost\u002Fexample",[1570]," will serve ",[1566,2696,2697],{"href":2697,"rel":2698},"https:\u002F\u002Fexample.com",[1570]," page",[24,2701,2702,2694,2706,2699],{},[1566,2703,2704],{"href":2704,"rel":2705},"http:\u002F\u002Flocalhost\u002Fwiki",[1570],[1566,2707,2708],{"href":2708,"rel":2709},"https:\u002F\u002Fwww.wikipedia.org",[1570],[11,2711,2712,2713,2715],{},"Put the below content in ",[78,2714,2088],{}," file",[71,2717,2719],{"className":2192,"code":2718,"language":2194,"meta":76,"style":76},"user nginx;\nworker_processes auto;\n\nevents {\n\n}\n\nhttp {\n    server {\n        listen 80;\n        server_name _;\n\n        location \u002Fexample\u002F {\n            proxy_pass https:\u002F\u002Fexample.com\u002F;\n        }\n\n        location \u002Fwiki\u002F {\n            proxy_pass https:\u002F\u002Fwww.wikipedia.org\u002F;\n        }\n    }\n}\n",[78,2720,2721,2725,2729,2733,2737,2741,2745,2749,2753,2757,2761,2765,2769,2774,2779,2783,2787,2792,2797,2801,2805],{"__ignoreMap":76},[81,2722,2723],{"class":83,"line":84},[81,2724,2215],{},[81,2726,2727],{"class":83,"line":95},[81,2728,2220],{},[81,2730,2731],{"class":83,"line":319},[81,2732,978],{"emptyLinePlaceholder":977},[81,2734,2735],{"class":83,"line":328},[81,2736,2234],{},[81,2738,2739],{"class":83,"line":891},[81,2740,978],{"emptyLinePlaceholder":977},[81,2742,2743],{"class":83,"line":899},[81,2744,2243],{},[81,2746,2747],{"class":83,"line":910},[81,2748,978],{"emptyLinePlaceholder":977},[81,2750,2751],{"class":83,"line":921},[81,2752,2252],{},[81,2754,2755],{"class":83,"line":931},[81,2756,2257],{},[81,2758,2759],{"class":83,"line":942},[81,2760,2553],{},[81,2762,2763],{"class":83,"line":950},[81,2764,2558],{},[81,2766,2767],{"class":83,"line":959},[81,2768,978],{"emptyLinePlaceholder":977},[81,2770,2771],{"class":83,"line":967},[81,2772,2773],{},"        location \u002Fexample\u002F {\n",[81,2775,2776],{"class":83,"line":974},[81,2777,2778],{},"            proxy_pass https:\u002F\u002Fexample.com\u002F;\n",[81,2780,2781],{"class":83,"line":981},[81,2782,2271],{},[81,2784,2785],{"class":83,"line":989},[81,2786,978],{"emptyLinePlaceholder":977},[81,2788,2789],{"class":83,"line":999},[81,2790,2791],{},"        location \u002Fwiki\u002F {\n",[81,2793,2794],{"class":83,"line":1006},[81,2795,2796],{},"            proxy_pass https:\u002F\u002Fwww.wikipedia.org\u002F;\n",[81,2798,2799],{"class":83,"line":1017},[81,2800,2271],{},[81,2802,2803],{"class":83,"line":1028},[81,2804,2276],{},[81,2806,2807],{"class":83,"line":1037},[81,2808,2243],{},[11,2810,2601],{},[11,2812,2604,2813,2608],{},[78,2814,2607],{},[71,2816,2818],{"className":73,"code":2817,"language":75,"meta":76,"style":76},"cd nginx_example\n\ndocker run --rm --name web_server -p 80:80 -v .\u002Fnginx.conf:\u002Fetc\u002Fnginx\u002Fnginx.conf nginx\n",[78,2819,2820,2826,2830],{"__ignoreMap":76},[81,2821,2822,2824],{"class":83,"line":84},[81,2823,2618],{"class":91},[81,2825,2621],{"class":101},[81,2827,2828],{"class":83,"line":95},[81,2829,978],{"emptyLinePlaceholder":977},[81,2831,2832,2834,2836,2838,2840,2842,2844,2846,2848,2850],{"class":83,"line":319},[81,2833,2044],{"class":87},[81,2835,2047],{"class":101},[81,2837,2050],{"class":91},[81,2839,2053],{"class":91},[81,2841,2056],{"class":101},[81,2843,2059],{"class":91},[81,2845,2062],{"class":101},[81,2847,2644],{"class":91},[81,2849,2652],{"class":101},[81,2851,2065],{"class":101},[11,2853,2854],{},"In your browser visit:",[339,2856,2857,2862],{},[24,2858,2859],{},[1566,2860,2692],{"href":2692,"rel":2861},[1570],[24,2863,2864],{},[1566,2865,2704],{"href":2704,"rel":2866},[1570],[44,2868,1617],{"id":1616},[11,2870,2871],{},"For me, learning about Nginx was more than just understanding another tool. it gave me clarity on how the internet really works behind the scenes.",[11,2873,2874,2875,2878],{},"At first, I always thought a ",[78,2876,2877],{},"web server"," was just something that shows HTML files, but now I realize it’s the backbone that keeps websites fast, reliable, and secure.",[11,2880,2881],{},"While experimenting, I personally liked:",[21,2883,2884,2887,2894,2897],{},[24,2885,2886],{},"How easy it was to run Nginx inside Docker with just one command.",[24,2888,2889,2890,2893],{},"The simplicity of serving my own ",[78,2891,2892],{},"Hello World"," page in a container.",[24,2895,2896],{},"Seeing reverse proxy in action which felt powerful because it showed how requests can be routed seamlessly.",[24,2898,2899],{},"The event handling architecture of nginx is just pure engineering.",[11,2901,2902],{},"Overall, I find Nginx not only useful for production systems but also a great learning tool to understand networking, load balancing, and scalability.",[11,2904,2905],{},"Writing this blog was part of my journey to simplify these concepts, and I hope it helps others get started with Nginx the way I did.",[44,2907,2909],{"id":2908},"resources","Resources",[339,2911,2912,2919,2926],{},[24,2913,2914],{},[1566,2915,2918],{"href":2916,"rel":2917},"https:\u002F\u002Fnginx.org\u002Fen\u002Fdocs\u002F",[1570],"Nginx Documnetation",[24,2920,2921],{},[1566,2922,2925],{"href":2923,"rel":2924},"https:\u002F\u002Fyoutu.be\u002FiInUBOVeBCc?si=ztRXCbfg0F_bA3Wy",[1570],"NGINX Explained - What is Nginx",[24,2927,2928],{},[1566,2929,2932],{"href":2930,"rel":2931},"https:\u002F\u002Fyoutu.be\u002FvVYM2QBk-iQ?si=QVLyA99kDAkAFKM-",[1570],"NGINX Internal Architecture - Workers",[1631,2934,2935],{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .shJU0, html code.shiki .shJU0{--shiki-default:#22863A}",{"title":76,"searchDepth":95,"depth":95,"links":2937},[2938,2939,2940,2946,2947,2950,2951,2952,2953],{"id":1714,"depth":95,"text":1715},{"id":1730,"depth":95,"text":1731},{"id":1757,"depth":95,"text":1758,"children":2941},[2942,2943,2944,2945],{"id":1812,"depth":319,"text":1813},{"id":1858,"depth":319,"text":1859},{"id":1898,"depth":319,"text":1899},{"id":1938,"depth":319,"text":1939},{"id":2022,"depth":95,"text":2023},{"id":1179,"depth":95,"text":1180,"children":2948},[2949],{"id":2158,"depth":319,"text":2159},{"id":2290,"depth":95,"text":2291},{"id":2678,"depth":95,"text":2679},{"id":1616,"depth":95,"text":1617},{"id":2908,"depth":95,"text":2909},"2025-10-01","What web servers actually do, how Nginx handles thousands of concurrent connections with its event-driven architecture, and how to configure it for real workloads.",{},"\u002Fblogs\u002Fwhat_is_web_server_and_nginx_role_in_it",{"title":1709,"description":2955},"blogs\u002Fwhat_is_web_server_and_nginx_role_in_it\u002Findex",[2961,2962,2044,2963,2146,2877],"programming language","computer science","containerization","SNVQNRezGJ1LUEXpZHQtts_rpxbgJO-CzCKf_-vu_7M",{"id":2966,"title":2967,"body":2968,"date":4028,"description":4029,"draft":1693,"extension":1694,"image":3000,"meta":4030,"navigation":977,"path":4031,"seo":4032,"stem":4033,"tags":4034,"__hash__":4039},"blogs\u002Fblogs\u002Fssl_and_tls\u002Findex.md","A Deep Dive into SSL\u002FTLS: The Protocols That Secure the Internet",{"type":8,"value":2969,"toc":4010},[2970,2973,2992,2995,3001,3004,3010,3014,3017,3037,3052,3058,3062,3090,3096,3100,3103,3205,3211,3214,3224,3227,3230,3233,3237,3240,3243,3246,3311,3317,3321,3324,3350,3354,3357,3428,3431,3435,3450,3453,3506,3509,3513,3516,3521,3524,3537,3543,3546,3551,3560,3566,3571,3574,3620,3625,3628,3670,3674,3680,3683,3709,3712,3716,3722,3725,3739,3750,3754,3760,3763,3770,3806,3818,3822,3828,3835,3838,3941,3945,3952,3991,3994,3996,4005,4007],[11,2971,2972],{},"SSL (Secure Sockets Layer) and its successor, TLS (Transport Layer Security), are the cryptographic protocols that secure data transmitted over the Internet. They ensure:",[21,2974,2975,2981,2987],{},[24,2976,2977,2980],{},[149,2978,2979],{},"Confidentiality:"," Your data is only accessible to the client and server.",[24,2982,2983,2986],{},[149,2984,2985],{},"Integrity:"," Your data is not altered in transit.",[24,2988,2989,2991],{},[149,2990,737],{}," You are communicating with the real server.",[11,2993,2994],{},"When you see the padlock icon in your browser, that’s TLS protecting your connection.",[11,2996,2997],{},[39,2998],{"alt":2999,"src":3000},"TLS","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Fconnection_secure.jpg",[11,3002,3003],{},"SSL was the original protocol developed at Netscape in 1994, but it is now obsolete due to security flaws. TLS is its modern, secure successor. Today, when people say \"SSL,\" they almost always mean \"TLS.\" The current version, TLS 1.3, is faster and more secure than its predecessors.",[11,3005,3006],{},[39,3007],{"alt":3008,"src":3009},"TLS history","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Ftls_history.png",[44,3011,3013],{"id":3012},"the-internet-a-network-of-networks","The Internet: A Network of Networks",[11,3015,3016],{},"At its core, the Internet is not one big \"thing\" owned by a single company. it’s thousands of independent networks connected together. These networks belong to:",[21,3018,3019,3022,3025,3028,3031,3034],{},[24,3020,3021],{},"Internet Service Providers (ISPs)",[24,3023,3024],{},"Telecom companies",[24,3026,3027],{},"Cloud providers (e.g., AWS, Azure, GCP)",[24,3029,3030],{},"Enterprises",[24,3032,3033],{},"Governments",[24,3035,3036],{},"Universities",[11,3038,3039,3040,3045,3046,3051],{},"Each network is called an ",[1566,3041,3044],{"href":3042,"rel":3043},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FAutonomous_system_(Internet)",[1570],"Autonomous System"," (AS), and they peer with each other using protocols like ",[1566,3047,3050],{"href":3048,"rel":3049},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBorder_Gateway_Protocol",[1570],"Border Gateway Protocol"," (BGP) to share routes.",[11,3053,3054],{},[39,3055],{"alt":3056,"src":3057},"The internet","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Fbgp.jpeg",[63,3059,3061],{"id":3060},"what-is-an-autonomous-system-as","What is an Autonomous System (AS)?",[21,3063,3064,3067,3070,3073],{},[24,3065,3066],{},"An Autonomous System is a collection of IP networks (prefixes) that are managed by a single organization and that share a common routing policy.",[24,3068,3069],{},"Each AS has a globally unique number called an Autonomous System Number (ASN).",[24,3071,3072],{},"Routers inside an AS speak internal routing protocols (like OSPF, IS-IS, or iBGP), and communicate with other AS using BGP (Border Gateway Protocol).",[24,3074,3075,3076],{},"Example:\n",[339,3077,3078,3081,3084,3087],{},[24,3079,3080],{},"Google (AS15169)",[24,3082,3083],{},"Cloudflare (AS13335)",[24,3085,3086],{},"Jio(AS55836)",[24,3088,3089],{},"Airtel(AS9498)",[11,3091,3092],{},[39,3093],{"alt":3094,"src":3095},"Autonomous system","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Fas_network.png",[63,3097,3099],{"id":3098},"why-asns-matter-and-who-assigns-it","Why ASNs matter and who Assigns it ?",[11,3101,3102],{},"There is a hierarchy of organizations that manage Internet number resources (IP addresses and ASNs):",[339,3104,3105,3119,3167,3194],{},[24,3106,3107,3108],{},"IANA (Internet Assigned Numbers Authority)",[21,3109,3110,3113,3116],{},[24,3111,3112],{},"IANA is at the top level.",[24,3114,3115],{},"It manages global IP address space and ASN pools.",[24,3117,3118],{},"It is operated by ICANN (Internet Corporation for Assigned Names and Numbers).",[24,3120,3121,3122],{},"RIRs (Regional Internet Registries)",[21,3123,3124,3127,3135,3143,3151,3159],{},[24,3125,3126],{},"IANA delegates blocks of IP addresses and ASN ranges to 5 RIRs, each covering a specific region:",[24,3128,3129,3134],{},[1566,3130,3133],{"href":3131,"rel":3132},"https:\u002F\u002Farin.net",[1570],"ARIN"," (North America)",[24,3136,3137,3142],{},[1566,3138,3141],{"href":3139,"rel":3140},"https:\u002F\u002Flacnic.net",[1570],"LACNIC"," (Latin America & Caribbean)",[24,3144,3145,3150],{},[1566,3146,3149],{"href":3147,"rel":3148},"https:\u002F\u002Fripe.net",[1570],"RIPE NCC"," (Europe, Middle East, parts of Central Asia)",[24,3152,3153,3158],{},[1566,3154,3157],{"href":3155,"rel":3156},"https:\u002F\u002Fapnic.net",[1570],"APNIC"," (Asia Pacific)",[24,3160,3161,3166],{},[1566,3162,3165],{"href":3163,"rel":3164},"https:\u002F\u002Fafrinic.net",[1570],"AFRINIC"," (Africa)",[24,3168,3169,3170],{},"NIRs (National Internet Registries)",[21,3171,3172,3175],{},[24,3173,3174],{},"In some regions, there are National Internet Registries (NIRs) that further manage allocation within a country.",[24,3176,3177,3178],{},"For example these are some NIRs operating under APNIC:\n",[21,3179,3180,3188,3191],{},[24,3181,3182,3187],{},[1566,3183,3186],{"href":3184,"rel":3185},"https:\u002F\u002Fwww.irinn.in\u002F",[1570],"IRINN",", Indian Registry for Internet Names and Numbers",[24,3189,3190],{},"CNNIC, China Internet Network Information Center",[24,3192,3193],{},"JPNIC, Japan Network Information Center",[24,3195,3196,3197],{},"Local ISPs, Enterprises, Organizations",[21,3198,3199,3202],{},[24,3200,3201],{},"These entities apply to their RIR or NIR to request an ASN.\n-They must justify why they need an ASN (usually because they plan to run BGP with other networks).",[24,3203,3204],{},"Once assigned, they are globally registered.",[11,3206,3207],{},[39,3208],{"alt":3209,"src":3210},"IANA","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Fiana.jpeg",[11,3212,3213],{},"Every BGP router announces IP prefixes with its ASN as it helps establish routing policies, peering agreements, and routing decisions.",[11,3215,3216,3217,3219,3220],{},"When you visit ",[78,3218,130],{},", your data may flow through:\n",[39,3221],{"alt":3222,"src":3223},"ASNs traffic","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Fasn_traffic.png",[11,3225,3226],{},"Each router uses BGP to decide how to route traffic across AS boundaries.",[11,3228,3229],{},"Since your packets cross multiple ASes you don’t control. Any compromised router in any AS could inspect or modify unencrypted traffic.",[11,3231,3232],{},"TLS ensures that even though your data flows through all these ASes, only you and the server can read it.",[44,3234,3236],{"id":3235},"how-ssltls-protects-your-data","How SSL\u002FTLS protects your data ?",[11,3238,3239],{},"When you connect to a website over HTTPS, TLS works behind the scenes to secure your connection.",[11,3241,3242],{},"Since your data is flowing through someone else networks and routers to the destination server anyone in midle can read and write to the data.",[11,3244,3245],{},"TLS protects your data in three key ways:",[339,3247,3248,3271,3291],{},[24,3249,3250,3251],{},"Confidentiality",[21,3252,3253,3256,3262,3265,3268],{},[24,3254,3255],{},"Data is only accessible by client and server.",[24,3257,3258,3259,1187],{},"TLS achieves confidentiality through a cryptographic technique called ",[78,3260,3261],{},"Encryption",[24,3263,3264],{},"TLS encrypts all the data you send and receive.",[24,3266,3267],{},"Even if someone intercepts your traffic (e.g. ISP, hacker, rogue router), they only see scrambled, unreadable data.",[24,3269,3270],{},"Only your browser and the server have the keys to decrypt the data.",[24,3272,3273,3274],{},"Integrity",[21,3275,3276,3279,3285,3288],{},[24,3277,3278],{},"Data hasn't been modified between client and server.",[24,3280,3281,3282,1187],{},"TLS achieves integrity through a cryptographic technique called ",[78,3283,3284],{},"Hashing",[24,3286,3287],{},"TLS ensures that the data hasn't been tampered with during transmission but it does't prevent from modification.",[24,3289,3290],{},"If any data is altered, it will be detected instantly and the connection will fail.",[24,3292,3293,3294],{},"Authentication",[21,3295,3296,3299,3305,3308],{},[24,3297,3298],{},"Client and server are indeed who they say they are.",[24,3300,3301,3302,1187],{},"TLS achieves authentication through a system called ",[78,3303,3304],{},"PKI (Pulbic key infrastructure)",[24,3306,3307],{},"TLS verifies the identity of the server using digital certificates issued by trusted Certificate Authorities (CAs).",[24,3309,3310],{},"This prevents attackers from impersonating a real website (e.g., phishing, man-in-the-middle attacks).",[11,3312,3313],{},[39,3314],{"alt":3315,"src":3316},"TLS 3 ways","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Ftls_3_ways.png",[44,3318,3320],{"id":3319},"key-players-of-ssl-tls","Key players of SSL & TLS",[11,3322,3323],{},"Understanding TLS requires knowing the three main actors involved in the process:",[339,3325,3326,3332,3344],{},[24,3327,3328,3331],{},[149,3329,3330],{},"The Client",": This is the application that initiates the secure connection. Most commonly, this is your web browser (like Chrome, Firefox, or Safari) when you visit a website. However, it can be any application that needs to communicate securely, such as an email client or a mobile app.",[24,3333,3334,3337,3338,177,3340,3343],{},[149,3335,3336],{},"The Server",": This is the machine that the client wants to communicate with. It hosts the website or service (e.g., ",[78,3339,130],{},[78,3341,3342],{},"your-bank.com","). The server holds the digital certificate and the private key necessary to prove its identity and establish a secure connection.",[24,3345,3346,3349],{},[149,3347,3348],{},"The Certificate Authority (CA)",": A Certificate Authority is a trusted third-party organization that issues digital certificates. Its job is to verify the identity of the server's owner before issuing a certificate. This is crucial for the \"Authentication\" part of TLS. When you browser sees a certificate from a trusted CA (like Let's Encrypt, DigiCert, or GlobalSign), it knows it can trust that the server is who it claims to be. Your browser and operating system come with a pre-installed list of trusted CAs.",[44,3351,3353],{"id":3352},"server-verification-and-certificate-types","Server Verification and Certificate Types",[11,3355,3356],{},"Before a Certificate Authority (CA) issues a certificate, it must verify that the entity requesting it is who they say they are. The rigor of this verification process determines the type of certificate issued. This is crucial for establishing trust. There are three main levels of validation:",[339,3358,3359,3384,3406],{},[24,3360,3361,3364],{},[149,3362,3363],{},"Domain Validation (DV) Certificates:",[21,3365,3366,3372,3378],{},[24,3367,3368,3371],{},[149,3369,3370],{},"Verification Level:"," This is the most basic level of validation. The CA only verifies that the applicant controls the domain name. This is usually done by email verification, adding a DNS record, or uploading a specific file to the website.",[24,3373,3374,3377],{},[149,3375,3376],{},"Trust Level:"," It confirms that your connection is encrypted and that you are connected to the correct domain, but it doesn't verify who owns the domain.",[24,3379,3380,3383],{},[149,3381,3382],{},"Best for:"," Blogs, personal websites, and small projects where identity assurance is not a high priority. Let's Encrypt is a popular provider of free DV certificates.",[24,3385,3386,3389],{},[149,3387,3388],{},"Organization Validation (OV) Certificates:",[21,3390,3391,3396,3401],{},[24,3392,3393,3395],{},[149,3394,3370],{}," This involves a more substantial vetting process. The CA verifies not only domain control but also the legal existence and details of the organization (e.g., name, city, country). This requires submitting business registration documents.",[24,3397,3398,3400],{},[149,3399,3376],{}," Provides a higher level of trust by confirming the identity of the legal entity behind the website. Users can view these details in the certificate information in their browser.",[24,3402,3403,3405],{},[149,3404,3382],{}," E-commerce sites, public-facing corporate websites, and services that handle sensitive user information.",[24,3407,3408,3411],{},[149,3409,3410],{},"Extended Validation (EV) Certificates:",[21,3412,3413,3418,3423],{},[24,3414,3415,3417],{},[149,3416,3370],{}," This is the highest level of validation and involves a strict, globally standardized vetting process defined by the CA\u002FBrowser Forum. The CA performs a thorough background check on the organization, verifying its legal, physical, and operational existence.",[24,3419,3420,3422],{},[149,3421,3376],{}," Offers the highest level of trust and assurance. In the past, browsers would display the company's name in a green address bar, though this UI has been mostly phased out. Still, the verified company name is visible in the certificate details.",[24,3424,3425,3427],{},[149,3426,3382],{}," Financial institutions (banks), government agencies, and large enterprises where proving identity and building user trust is paramount.",[11,3429,3430],{},"Choosing the right certificate type depends on the website's purpose and the level of trust it needs to establish with its users.",[44,3432,3434],{"id":3433},"encryption-and-confidentiality","Encryption and Confidentiality",[11,3436,3437,3438,3441,3442,3445,3446,3449],{},"Encryption is the process of converting plaintext data into a scrambled, unreadable format called ",[149,3439,3440],{},"ciphertext",". This is the core mechanism TLS uses to ensure ",[149,3443,3444],{},"confidentiality",". Only parties with the correct ",[149,3447,3448],{},"key"," can decrypt the ciphertext back into its original, readable form.",[11,3451,3452],{},"TLS cleverly uses two types of encryption:",[339,3454,3455,3490],{},[24,3456,3457,3460],{},[149,3458,3459],{},"Asymmetric Encryption (Public-Key Cryptography):",[21,3461,3462,3472,3475,3483],{},[24,3463,3464,3465,3468,3469,1187],{},"This involves a pair of keys: a ",[149,3466,3467],{},"public key"," and a ",[149,3470,3471],{},"private key",[24,3473,3474],{},"The public key can be shared with anyone. The private key must be kept secret by the owner (in this case, the server).",[24,3476,3477,3478,3482],{},"Data encrypted with the public key can ",[3479,3480,3481],"em",{},"only"," be decrypted with the corresponding private key.",[24,3484,3485,3486,3489],{},"TLS uses asymmetric encryption during the initial ",[149,3487,3488],{},"handshake"," to securely exchange a key for symmetric encryption. This is crucial for establishing a secure channel without having to pre-share a secret.",[24,3491,3492,3495],{},[149,3493,3494],{},"Symmetric Encryption:",[21,3496,3497,3500,3503],{},[24,3498,3499],{},"This uses a single, shared secret key for both encryption and decryption.",[24,3501,3502],{},"It is much faster and more efficient for encrypting large amounts of data than asymmetric encryption.",[24,3504,3505],{},"Once the initial handshake is complete, the client and server use the securely exchanged symmetric key to encrypt all the actual application data (like your HTTP requests and the website's responses).",[11,3507,3508],{},"By combining these two methods, TLS gets the best of both worlds: the secure key exchange capability of asymmetric encryption and the high performance of symmetric encryption for the bulk of the data transfer.",[44,3510,3512],{"id":3511},"a-closer-look-at-asymmetric-encryption-how-rsa-works","A Closer Look at Asymmetric Encryption: How RSA Works",[11,3514,3515],{},"The RSA (Rivest-Shamir-Adleman) algorithm is the most well-known asymmetric encryption algorithm. Its security is based on the practical difficulty of factoring the product of two large prime numbers.",[11,3517,3518],{},[149,3519,3520],{},"The Core Concept: A Mailbox Analogy",[11,3522,3523],{},"Imagine you have a special mailbox with two keys:",[21,3525,3526,3532],{},[24,3527,3528,3529,3531],{},"A ",[149,3530,3467],{}," (the mailbox slot): You can make copies of this key and give it to anyone. Anyone with this key can open the slot and drop a message in.",[24,3533,3528,3534,3536],{},[149,3535,3471],{}," (the mailbox door key): This key is yours alone. It is the only key that can open the mailbox door to retrieve the messages.",[11,3538,3539],{},[39,3540],{"alt":3541,"src":3542},"RSA Mailbox Analogy","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Frsa_email_analogy.webp",[11,3544,3545],{},"This is the essence of RSA. The server's public key is like the mailbox slot, and its private key is the only thing that can unlock the messages sent to it.",[11,3547,3548],{},[149,3549,3550],{},"A Demo: RSA in Action",[11,3552,3553,3554,3556,3557,3559],{},"Let's see how this is used for both ",[149,3555,3250],{}," (encryption) and ",[149,3558,3293],{}," (digital signatures).",[11,3561,3562],{},[39,3563],{"alt":3564,"src":3565},"Signature vs. Encryption","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Fencryption_vs_signature.png",[11,3567,3568],{},[149,3569,3570],{},"1. For Confidentiality (Encrypting the Session Key):",[11,3572,3573],{},"This is the primary role of RSA in the TLS handshake.",[21,3575,3576,3584,3590,3599,3605,3614],{},[24,3577,3578,3581,3582,1187],{},[149,3579,3580],{},"Step 1:"," The Server sends its certificate to the Client. This certificate contains the Server's ",[149,3583,3467],{},[24,3585,3586,3589],{},[149,3587,3588],{},"Step 2:"," The Client generates a small, random piece of data (the \"pre-master secret\") that will be used to create the final session key.",[24,3591,3592,3595,3596,3598],{},[149,3593,3594],{},"Step 3:"," The Client uses the Server's ",[149,3597,3467],{}," to encrypt this pre-master secret. Now, it's just scrambled, unreadable data.",[24,3600,3601,3604],{},[149,3602,3603],{},"Step 4:"," The Client sends this encrypted data to the Server.",[24,3606,3607,3610,3611,3613],{},[149,3608,3609],{},"Step 5:"," The Server uses its ",[149,3612,3471],{}," to decrypt the data and retrieve the pre-master secret. No one else could have done this, because no one else has the private key.",[24,3615,3616,3619],{},[149,3617,3618],{},"Result:"," Both the Client and Server now share a secret, which they use to independently generate the same symmetric session key. Confidentiality is achieved.",[11,3621,3622],{},[149,3623,3624],{},"2. For Authentication (How a CA Signs a Certificate):",[11,3626,3627],{},"RSA also works in reverse for digital signatures, which is how a CA guarantees a certificate is authentic.",[21,3629,3630,3635,3640,3651,3656,3665],{},[24,3631,3632,3634],{},[149,3633,3580],{}," A server owner gives their certificate information (domain name, public key, etc.) to a Certificate Authority (CA).",[24,3636,3637,3639],{},[149,3638,3588],{}," The CA creates a hash of all that information.",[24,3641,3642,3644,3645,3647,3648,1187],{},[149,3643,3594],{}," The CA uses its own ",[149,3646,3471],{}," to encrypt that hash. This encrypted hash is the ",[149,3649,3650],{},"digital signature",[24,3652,3653,3655],{},[149,3654,3603],{}," The CA attaches this signature to the certificate and sends it back to the server owner.",[24,3657,3658,3661,3662,3664],{},[149,3659,3660],{},"Step 5 (Verification):"," When your browser receives the certificate, it sees it was signed by the CA. Your browser already trusts this CA and has its ",[149,3663,3467],{},". It uses the CA's public key to decrypt the signature, revealing the original hash. It then computes its own hash of the certificate. If the two hashes match, the signature is valid.",[24,3666,3667,3669],{},[149,3668,3618],{}," Your browser has just mathematically proven that the certificate is authentic and has not been tampered with. Authentication is achieved.",[44,3671,3673],{"id":3672},"hashing-hashing-algorithms-and-collisions","Hashing, Hashing algorithms and Collisions",[11,3675,3676,3677,1187],{},"Hashing is a fundamental concept in cryptography that ensures data integrity. It's the process of taking an input (of any size) and running it through a mathematical function to produce a fixed-size output string, known as a ",[149,3678,3679],{},"hash",[11,3681,3682],{},"A good hashing algorithm is:",[21,3684,3685,3691,3697,3703],{},[24,3686,3687,3690],{},[149,3688,3689],{},"Deterministic",": The same input will always produce the same hash.",[24,3692,3693,3696],{},[149,3694,3695],{},"Efficient",": The hash is quick to compute.",[24,3698,3699,3702],{},[149,3700,3701],{},"Pre-image Resistant",": It's computationally impossible to determine the original input from its hash. This makes it a one-way function.",[24,3704,3705,3708],{},[149,3706,3707],{},"Collision Resistant",": It should be extremely difficult to find two different inputs that produce the same hash.",[11,3710,3711],{},"Common hashing algorithms include SHA-256 (Secure Hash Algorithm 256-bit), which is widely used today. Older algorithms like MD5 and SHA-1 are now considered insecure because \"collisions\" have been found. A collision means two different inputs produce the same hash, which can allow an attacker to pass off a malicious file as a legitimate one.",[44,3713,3715],{"id":3714},"data-integrity-how-tls-uses-hashing","Data integrity - How TLS uses Hashing",[11,3717,3718,3719,1187],{},"So how does TLS use hashing to ensure data hasn't been tampered with? It uses a clever mechanism called an ",[149,3720,3721],{},"HMAC (Hash-based Message Authentication Code)",[11,3723,3724],{},"Here’s how it works:",[339,3726,3727,3730,3733,3736],{},[24,3728,3729],{},"During the initial TLS handshake, the client and server securely negotiate a shared secret key.",[24,3731,3732],{},"For every message they exchange, the sender combines the message content with the secret key and then hashes the result. This creates the HMAC, which is attached to the message.",[24,3734,3735],{},"The receiver gets the message and the HMAC. It independently computes its own HMAC using the message content and the shared secret key it already has.",[24,3737,3738],{},"If the received HMAC matches the one it just computed, the data is considered authentic and unaltered. If they don't match, the connection is terminated immediately, as this indicates tampering.",[11,3740,3741,3742,3745,3746,3749],{},"This process guarantees both ",[149,3743,3744],{},"integrity"," (the data wasn't changed) and ",[149,3747,3748],{},"authentication"," (we know who sent it, because only they have the secret key).",[44,3751,3753],{"id":3752},"what-is-a-cipher-suite","What is a Cipher Suite?",[11,3755,3756],{},[39,3757],{"alt":3758,"src":3759},"Cipher Suite Bundle","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Fcipher.png",[11,3761,3762],{},"A cipher suite is a bundle of algorithms that, together, provide all the security guarantees of TLS. Think of it as a single name that defines the exact tools for the job. During the handshake, the client sends a list of cipher suites it supports (its \"menu\" of security options), and the server chooses the one it prefers, usually the strongest one they both support.",[11,3764,3765,3766,3769],{},"A typical cipher suite name, like ",[78,3767,3768],{},"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",", looks complex, but it's just a combination of four distinct types of algorithms, each mapping directly to a core TLS goal:",[339,3771,3772,3782,3790,3798],{},[24,3773,3774,3777,3778,3781],{},[149,3775,3776],{},"Key Exchange Algorithm (ECDHE):"," This algorithm's job is to let the client and server securely agree on a shared secret key for symmetric encryption, even if someone is listening in. This is the foundation for confidentiality. Using an \"ephemeral\" method like ECDHE provides ",[149,3779,3780],{},"Perfect Forward Secrecy",", meaning past conversations remain secure even if the server's long-term key is compromised later.",[24,3783,3784,3787,3788,1187],{},[149,3785,3786],{},"Authentication Algorithm (RSA):"," This determines how the server proves its identity to the client. The server uses this algorithm (e.g., RSA) to sign its certificate, proving it owns the corresponding private key. This directly provides ",[149,3789,3293],{},[24,3791,3792,3795,3796,1187],{},[149,3793,3794],{},"Bulk Encryption Algorithm (AES_128_GCM):"," This is the high-speed symmetric cipher that will encrypt all the actual data (your requests, the website's content, etc.) after the handshake is complete. This provides ",[149,3797,3250],{},[24,3799,3800,3803,3804,1187],{},[149,3801,3802],{},"Hashing Algorithm (SHA256):"," This algorithm is used to create a Message Authentication Code (MAC), which is like a tamper-proof seal on every message. This provides ",[149,3805,3273],{},[11,3807,3808,3809,3811,3812,3814,3815,3817],{},"So, the cipher suite is the complete package. By agreeing on one, the client and server are explicitly defining how they will achieve ",[149,3810,3293],{},", ",[149,3813,3250],{},", and ",[149,3816,3273],{}," for the entire session.",[44,3819,3821],{"id":3820},"the-tls-handshake","The TLS Handshake",[11,3823,3824],{},[39,3825],{"alt":3826,"src":3827},"TLS Handshake Flow","\u002Fimages\u002Fblogs\u002Fssl_and_tls\u002Ftls-handshake.png",[11,3829,3830,3831,3834],{},"Now that we understand the key players and the types of encryption, let's walk through how they all come together in the ",[149,3832,3833],{},"TLS handshake",". This is the negotiation process that happens in milliseconds before any actual data is sent. The goal is simple: for the client and server to verify each other and securely agree on a session key for symmetric encryption.",[11,3836,3837],{},"Here’s a simplified look at the steps (for TLS 1.2, as it's a bit more explicit for learning, though TLS 1.3 is faster and more common today):",[339,3839,3840,3857,3874,3894,3923],{},[24,3841,3842,3845,3846],{},[149,3843,3844],{},"Client Hello",": The client sends a \"hello\" message to the server. This message includes:",[21,3847,3848,3851,3854],{},[24,3849,3850],{},"The TLS versions it supports.",[24,3852,3853],{},"A list of cipher suites it can use (the combination of encryption, authentication, and hashing algorithms).",[24,3855,3856],{},"A random string of bytes, known as the \"Client Random.\"",[24,3858,3859,3862,3863],{},[149,3860,3861],{},"Server Hello",": The server receives the client's hello and responds with its own \"hello\" message. This includes:",[21,3864,3865,3868,3871],{},[24,3866,3867],{},"The TLS version and cipher suite it has chosen from the client's list.",[24,3869,3870],{},"Its digital certificate, which contains its public key.",[24,3872,3873],{},"Another random string of bytes, the \"Server Random.\"",[24,3875,3876,3879,3880],{},[149,3877,3878],{},"Certificate Verification",": The client examines the server's certificate. It checks:",[21,3881,3882,3885,3891],{},[24,3883,3884],{},"Is the certificate expired?",[24,3886,3887,3888,3890],{},"Is it for the correct domain (",[78,3889,130],{},", etc.)?",[24,3892,3893],{},"Is it signed by a Certificate Authority (CA) that the client trusts? (The client checks this against its built-in list of trusted CAs).\nIf any of these checks fail, the browser will show a security warning, and the connection is terminated.",[24,3895,3896,3899,3900],{},[149,3897,3898],{},"Key Exchange",": This is the clever part. The client generates another random string of bytes called the \"Pre-Master Secret.\"",[21,3901,3902,3908,3911,3917],{},[24,3903,3904,3905,3907],{},"The client encrypts this Pre-Master Secret using the server's ",[149,3906,3467],{}," (which it got from the certificate).",[24,3909,3910],{},"The client sends this encrypted Pre-Master Secret to the server.",[24,3912,3913,3914,3916],{},"Because it was encrypted with the public key, only the server, with its corresponding ",[149,3915,3471],{},", can decrypt it.",[24,3918,3919,3920,1187],{},"Now, both the client and server use the Client Random, Server Random, and the Pre-Master Secret to independently calculate the same ",[149,3921,3922],{},"session key",[24,3924,3925,3928,3929],{},[149,3926,3927],{},"Handshake Complete & Secure Communication",": The handshake is now finished.",[21,3930,3931,3934],{},[24,3932,3933],{},"Both client and server send a \"Finished\" message, which is encrypted with the newly created session key.",[24,3935,3936,3937,3940],{},"From this point on, all communication between the client and server is encrypted using this ",[149,3938,3939],{},"symmetric session key",", ensuring confidentiality and integrity for the rest of the session.",[44,3942,3944],{"id":3943},"how-to-inspect-a-websites-certificate","How to Inspect a Website's Certificate",[11,3946,3947,3948,3951],{},"Everything we've discussed is visible right in your browser. This is the best way to see how these concepts apply in the real world. Try this on any ",[78,3949,3950],{},"https:\u002F\u002F"," site:",[339,3953,3954,3960,3966],{},[24,3955,3956,3959],{},[149,3957,3958],{},"Click the Padlock:"," In your browser's address bar, click the padlock icon to the left of the website's URL.",[24,3961,3962,3965],{},[149,3963,3964],{},"View the Certificate:"," Look for an option that says \"Connection is secure,\" which will lead to a \"Certificate is valid\" button. Clicking this will open the certificate viewer.",[24,3967,3968,3971],{},[149,3969,3970],{},"What to Look For:",[21,3972,3973,3979,3985],{},[24,3974,3975,3978],{},[149,3976,3977],{},"Issued To:"," You'll see the \"Common Name\" (the domain the certificate belongs to) and often the organization's name, city, and country (for OV and EV certificates).",[24,3980,3981,3984],{},[149,3982,3983],{},"Issued By:"," This shows you which Certificate Authority (CA) verified and signed the certificate.",[24,3986,3987,3990],{},[149,3988,3989],{},"Validity Period:"," You can see the \"Not Before\" and \"Not After\" dates.",[11,3992,3993],{},"By doing this, you can directly see the results of the TLS handshake and verify the identity and security of the websites you visit.",[44,3995,1560],{"id":1559},[21,3997,3998],{},[24,3999,4000],{},[1566,4001,4004],{"href":4002,"rel":4003},"https:\u002F\u002Fyoutube.com\u002Fplaylist?list=PLIFyRwBY_4bTwRX__Zn4-letrtpSj1mzY&si=B5eft0GSTFOQ_d31",[1570],"Practical TLS Playlist",[44,4006,1617],{"id":1616},[11,4008,4009],{},"SSL\u002FTLS is a cornerstone of modern internet security. It works silently in the background, providing the essential guarantees of confidentiality, integrity, and authentication. While the process is complex, the result is a secure channel that protects our sensitive information from prying eyes and tampering.",{"title":76,"searchDepth":95,"depth":95,"links":4011},[4012,4016,4017,4018,4019,4020,4021,4022,4023,4024,4025,4026,4027],{"id":3012,"depth":95,"text":3013,"children":4013},[4014,4015],{"id":3060,"depth":319,"text":3061},{"id":3098,"depth":319,"text":3099},{"id":3235,"depth":95,"text":3236},{"id":3319,"depth":95,"text":3320},{"id":3352,"depth":95,"text":3353},{"id":3433,"depth":95,"text":3434},{"id":3511,"depth":95,"text":3512},{"id":3672,"depth":95,"text":3673},{"id":3714,"depth":95,"text":3715},{"id":3752,"depth":95,"text":3753},{"id":3820,"depth":95,"text":3821},{"id":3943,"depth":95,"text":3944},{"id":1559,"depth":95,"text":1560},{"id":1616,"depth":95,"text":1617},"2025-06-29","A comprehensive guide to understanding SSL, TLS, and the cryptographic protocols that ensure confidentiality, integrity, and authentication on the web.",{},"\u002Fblogs\u002Fssl_and_tls",{"title":2967,"description":4029},"blogs\u002Fssl_and_tls\u002Findex",[2999,4035,4036,4037,4038,1705],"SSL","HTTPS","Cryptography","Cybersecurity","knGjGGxsR4ep66di6DJhalhSC9oTNyzTAwP3Ge2Pw9A",{"id":4041,"title":4042,"body":4043,"date":6306,"description":6307,"draft":1693,"extension":1694,"image":4056,"meta":6308,"navigation":977,"path":6309,"seo":6310,"stem":6311,"tags":6312,"__hash__":6316},"blogs\u002Fblogs\u002Fkubernetes\u002Findex.md","Getting Started with Kubernetes for Developers",{"type":8,"value":4044,"toc":6274},[4045,4051,4057,4066,4069,4073,4179,4182,4239,4242,4246,4249,4252,4256,4264,4268,4276,4282,4284,4288,4291,4295,4309,4314,4318,4342,4347,4351,4372,4377,4381,4394,4399,4403,4425,4430,4434,4455,4460,4464,4488,4493,4495,4499,4506,4509,4516,4608,4612,4725,4729,4763,4767,4884,4887,4898,4907,5045,5050,5071,5076,5091,5094,5177,5179,5183,5187,5633,5637,5934,5938,6116,6120,6187,6191,6198,6200,6257,6259,6262,6265,6268,6271],[11,4046,4047,4050],{},[149,4048,4049],{},"Kubernetes"," also known as K8s is an open-source container orchestration system for automating software deployment, scaling, and management.",[11,4052,4053],{},[39,4054],{"alt":4055,"src":4056},"k8s logo","\u002Fimages\u002Fblogs\u002Fkubernetes\u002Fk8s-logo.png",[11,4058,4059,4060,4065],{},"Originally designed by Google, the project is now maintained by a worldwide community of contributors and the trademark is held by the ",[1566,4061,4064],{"href":4062,"rel":4063},"https:\u002F\u002Fwww.cncf.io",[1570],"CNCF","(Cloud Native Computing Foundation).",[11,4067,4068],{},"Kubernetes assembles one or more computers, either virtual machines or bare metal, into a cluster which can run workloads in containers.",[44,4070,4072],{"id":4071},"what-features-does-it-provide","What features does it provide ?",[339,4074,4075,4086,4097,4111,4128,4139,4162],{},[24,4076,4077,4078],{},"Container Orchestration",[21,4079,4080,4083],{},[24,4081,4082],{},"Automatically schedules and runs containers across a cluster of machines.",[24,4084,4085],{},"Abstracts away the infrastructure — developers just define what the app needs (YAML), Kubernetes handles the rest.",[24,4087,4088,4089],{},"Declarative Infrastructure",[21,4090,4091,4094],{},[24,4092,4093],{},"Everything in K8s is defined as YAML manifests.",[24,4095,4096],{},"Developers describe the desired state, and K8s ensures the system matches that.",[24,4098,4099,4100],{},"Self-Healing",[21,4101,4102,4105,4108],{},[24,4103,4104],{},"Automatically restarts failed containers",[24,4106,4107],{},"Reschedules Pods if a Node dies",[24,4109,4110],{},"Replaces containers if the health check fails",[24,4112,4113,4114],{},"Health checks",[21,4115,4116,4122],{},[24,4117,4118,4121],{},[78,4119,4120],{},"readinessProbe",": Tells K8s when the app is ready to serve traffic",[24,4123,4124,4127],{},[78,4125,4126],{},"livenessProbe",": Restarts app if it hangs or crashes",[24,4129,4130,4131],{},"Rolling Updates and Rollbacks",[21,4132,4133,4136],{},[24,4134,4135],{},"Updates can be applied gradually with zero downtime",[24,4137,4138],{},"Easy rollback to previous versions if the new one fails",[24,4140,4141,4142],{},"Services and Networking",[21,4143,4144,4151],{},[24,4145,4146,4147,4150],{},"Internal DNS service discovery (e.g: ",[78,4148,4149],{},"my-service.default.svc.cluster.local",")",[24,4152,4153,4154],{},"Supports:\n",[21,4155,4156,4159],{},[24,4157,4158],{},"ClusterIP (default, internal-only)",[24,4160,4161],{},"NodePort, LoadBalancer, Ingress, GatewayAPI for external access",[24,4163,4164,4165],{},"Secrets and ConfigMaps",[21,4166,4167,4173],{},[24,4168,4169,4172],{},[78,4170,4171],{},"ConfigMap",": Inject environment variables or config files into containers",[24,4174,4175,4178],{},[78,4176,4177],{},"Secret",": Securely store API keys, passwords, etc.",[11,4180,4181],{},"Developers should never hardcode secrets — use these instead.",[339,4183,4184,4195,4206,4217],{"start":921},[24,4185,4186,4187],{},"Volumes and Persistent Storage",[21,4188,4189,4192],{},[24,4190,4191],{},"Store data outside containers via PersistentVolumeClaims (PVCs)",[24,4193,4194],{},"Good for databases or any app that needs persistent state",[24,4196,4197,4198],{},"Namespaces",[21,4199,4200,4203],{},[24,4201,4202],{},"Isolate environments (e.g., dev, staging, prod) within a single cluster",[24,4204,4205],{},"Developers can test without affecting production",[24,4207,4208,4209],{},"RBAC (Role-Based Access Control)",[21,4210,4211,4214],{},[24,4212,4213],{},"Controls who can deploy, read logs, access resources",[24,4215,4216],{},"Essential for teams — especially on shared clusters",[24,4218,4219,4220],{},"Observability",[21,4221,4222,4236],{},[24,4223,4224,4225],{},"Native support for:\n",[21,4226,4227,4233],{},[24,4228,4229,4230,4150],{},"Logs (",[78,4231,4232],{},"kubectl logs",[24,4234,4235],{},"Metrics (via Prometheus)",[24,4237,4238],{},"Great for debugging and monitoring performance.",[4240,4241],"hr",{},[44,4243,4245],{"id":4244},"what-is-a-kubernetes-cluster","What is a Kubernetes Cluster ?",[11,4247,4248],{},"A Kubernetes cluster is a group of computers (called nodes) that work together to run your containerized applications. These nodes can be real machines or virtual ones.",[11,4250,4251],{},"There are two types of nodes in a Kubernetes cluster:",[63,4253,4255],{"id":4254},"_1-master-node-control-plane","1. Master node (Control Plane):",[21,4257,4258,4261],{},[24,4259,4260],{},"Think of it as the brain of the cluster.",[24,4262,4263],{},"It makes decisions, like where to run applications, handles scheduling, and keeps track of everything.",[63,4265,4267],{"id":4266},"_2-worker-nodes","2. Worker nodes:",[21,4269,4270,4273],{},[24,4271,4272],{},"These are the machines that actually run your apps inside containers.",[24,4274,4275],{},"Each worker node has a Kubelet (agent), a container runtime (like Docker or containerd), and tools for networking and monitoring.",[11,4277,4278],{},[39,4279],{"alt":4280,"src":4281},"k8s architecture","\u002Fimages\u002Fblogs\u002Fkubernetes\u002Fk8s-architecture.png",[4240,4283],{},[44,4285,4287],{"id":4286},"key-components-architecture","Key Components ( Architecture )",[11,4289,4290],{},"A Kubernetes cluster has many parts working together behind the scenes. Let’s break down the core components we should know:",[63,4292,4294],{"id":4293},"_1-api-server","1. API Server",[21,4296,4297,4300,4303,4306],{},[24,4298,4299],{},"Location: Control Plane",[24,4301,4302],{},"Acts as the front door of the Kubernetes cluster.",[24,4304,4305],{},"All communication (from users, CLI tools like kubectl, or even internal components) goes through the API Server.",[24,4307,4308],{},"It processes REST requests, validates them, and updates the cluster state in etcd.",[1874,4310,4311],{},[11,4312,4313],{},"Think of it as the receptionist of a company — every request passes through it first.",[63,4315,4317],{"id":4316},"_2-scheduler","2. Scheduler",[21,4319,4320,4322,4325,4339],{},[24,4321,4299],{},[24,4323,4324],{},"Responsible for assigning Pods to Nodes.",[24,4326,4327,4328],{},"It looks at:\n",[21,4329,4330,4333,4336],{},[24,4331,4332],{},"Resource requirements (CPU, memory)",[24,4334,4335],{},"Node availability",[24,4337,4338],{},"Taints\u002Ftolerations and affinities",[24,4340,4341],{},"It chooses the best node for each pod and tells the API server its decision.",[1874,4343,4344],{},[11,4345,4346],{},"Like a delivery manager assigning packages to the nearest delivery person.",[63,4348,4350],{"id":4349},"_3-conroller-manager","3. Conroller manager",[21,4352,4353,4355,4358],{},[24,4354,4299],{},[24,4356,4357],{},"Watches the cluster state and makes sure the current state matches the desired state (defined in YAML files).",[24,4359,4360,4361],{},"Contains multiple controllers:\n",[21,4362,4363,4366,4369],{},[24,4364,4365],{},"Node Controller – watches node health",[24,4367,4368],{},"ReplicaSet Controller – ensures the right number of pods are running",[24,4370,4371],{},"Job Controller, DaemonSet Controller, etc.",[1874,4373,4374],{},[11,4375,4376],{},"Imagine a robot checking every 5 seconds if your to-do list is being followed, and fixing anything that's off.",[63,4378,4380],{"id":4379},"_4-etcd","4. etcd",[21,4382,4383,4385,4388,4391],{},[24,4384,4299],{},[24,4386,4387],{},"A fast, distributed key-value store used as Kubernetes’ backbone database.",[24,4389,4390],{},"Stores all cluster data — deployments, state of pods, secrets, config maps, etc",[24,4392,4393],{},"Highly consistent and supports snapshots\u002Fbackup.",[1874,4395,4396],{},[11,4397,4398],{},"If the API server is the receptionist, etcd is the filing cabinet where everything is saved.",[63,4400,4402],{"id":4401},"_5-kubelet","5. Kubelet",[21,4404,4405,4408,4411],{},[24,4406,4407],{},"Location: Each Worker Node",[24,4409,4410],{},"An agent that runs on every worker node.",[24,4412,4413,4414],{},"It takes instructions from the API server and:\n",[21,4415,4416,4419,4422],{},[24,4417,4418],{},"Ensures containers are running",[24,4420,4421],{},"Monitors pod health",[24,4423,4424],{},"Reports back to the control plane",[1874,4426,4427],{},[11,4428,4429],{},"Like a local manager on each node making sure everything is working as planned.",[63,4431,4433],{"id":4432},"_6-kube-proxy","6. Kube-proxy",[21,4435,4436,4438,4441],{},[24,4437,4407],{},[24,4439,4440],{},"Manages networking and communication in the cluster.",[24,4442,4443,4444],{},"Handles:\n",[21,4445,4446,4449,4452],{},[24,4447,4448],{},"Routing traffic to the correct pod\u002Fservice",[24,4450,4451],{},"Load balancing",[24,4453,4454],{},"NAT rules for service access",[1874,4456,4457],{},[11,4458,4459],{},"Think of it as the node’s network engineer — setting up all the traffic rules so things run smoothly.",[63,4461,4463],{"id":4462},"_7-container-runtime","7. Container runtime",[21,4465,4466,4468,4471,4485],{},[24,4467,4407],{},[24,4469,4470],{},"Software that actually runs containers on a system.",[24,4472,4473,4474],{},"Kubernetes supports several runtimes:\n",[21,4475,4476,4479,4482],{},[24,4477,4478],{},"Docker (deprecated)",[24,4480,4481],{},"containerd",[24,4483,4484],{},"CRI-O",[24,4486,4487],{},"Kubelet communicates with this runtime to start\u002Fstop containers.",[1874,4489,4490],{},[11,4491,4492],{},"It's the engine that powers and runs your containers, like Docker or containerd.",[4240,4494],{},[44,4496,4498],{"id":4497},"local-k8s-cluster-setup","Local K8s cluster setup",[11,4500,4501,4502,4505],{},"We are going to use docker containers as a nodes and ",[78,4503,4504],{},"kind"," to setup the cluster.",[11,4507,4508],{},"To create a local k8s cluster we need following tools installed in our system.",[63,4510,4512,4513],{"id":4511},"_1-docker","1. ",[1566,4514,2031],{"href":4515},"\u002Fblogs\u002Fvirtualization_containers_and_role_of_docker_in_it\u002F#docker-installation-on-linux",[21,4517,4518,4544,4587],{},[24,4519,4520,4521],{},"Installation\n",[71,4522,4524],{"className":73,"code":4523,"language":75,"meta":76,"style":76},"curl -fsSL https:\u002F\u002Fget.docker.com | sh\n",[78,4525,4526],{"__ignoreMap":76},[81,4527,4528,4531,4534,4537,4541],{"class":83,"line":84},[81,4529,4530],{"class":87},"curl",[81,4532,4533],{"class":91}," -fsSL",[81,4535,4536],{"class":101}," https:\u002F\u002Fget.docker.com",[81,4538,4540],{"class":4539},"sD7c4"," |",[81,4542,4543],{"class":87}," sh\n",[24,4545,4546,4547,4549],{},"Allow running docker without ",[78,4548,1231],{},[71,4550,4552],{"className":73,"code":4551,"language":75,"meta":76,"style":76},"sudo groupadd docker\nsudo usermod -aG docker $USER\nnewgrp docker\n",[78,4553,4554,4564,4580],{"__ignoreMap":76},[81,4555,4556,4558,4561],{"class":83,"line":84},[81,4557,1231],{"class":87},[81,4559,4560],{"class":101}," groupadd",[81,4562,4563],{"class":101}," docker\n",[81,4565,4566,4568,4571,4574,4577],{"class":83,"line":95},[81,4567,1231],{"class":87},[81,4569,4570],{"class":101}," usermod",[81,4572,4573],{"class":91}," -aG",[81,4575,4576],{"class":101}," docker",[81,4578,4579],{"class":859}," $USER\n",[81,4581,4582,4585],{"class":83,"line":319},[81,4583,4584],{"class":87},"newgrp",[81,4586,4563],{"class":101},[24,4588,4589,4590,4593,4594],{},"Run a ",[78,4591,4592],{},"hello-world"," image\n",[71,4595,4597],{"className":73,"code":4596,"language":75,"meta":76,"style":76},"docker run hello-world\n",[78,4598,4599],{"__ignoreMap":76},[81,4600,4601,4603,4605],{"class":83,"line":84},[81,4602,2044],{"class":87},[81,4604,2047],{"class":101},[81,4606,4607],{"class":101}," hello-world\n",[63,4609,4611],{"id":4610},"_2-kubectl","2. Kubectl",[21,4613,4614,4709],{},[24,4615,4520,4616],{},[71,4617,4619],{"className":73,"code":4618,"language":75,"meta":76,"style":76},"curl -LO \"https:\u002F\u002Fdl.k8s.io\u002Frelease\u002F$(curl -L -s https:\u002F\u002Fdl.k8s.io\u002Frelease\u002Fstable.txt)\u002Fbin\u002Flinux\u002Famd64\u002Fkubectl\"\ncurl -LO \"https:\u002F\u002Fdl.k8s.io\u002Frelease\u002F$(curl -L -s https:\u002F\u002Fdl.k8s.io\u002Frelease\u002Fstable.txt)\u002Fbin\u002Flinux\u002Famd64\u002Fkubectl.sha256\"\necho \"$(cat kubectl.sha256)  kubectl\" | sha256sum --check\nsudo install -o root -g root -m 0755 kubectl \u002Fusr\u002Flocal\u002Fbin\u002Fkubectl\n",[78,4620,4621,4641,4658,4679],{"__ignoreMap":76},[81,4622,4623,4625,4628,4631,4633,4636,4638],{"class":83,"line":84},[81,4624,4530],{"class":87},[81,4626,4627],{"class":91}," -LO",[81,4629,4630],{"class":101}," \"https:\u002F\u002Fdl.k8s.io\u002Frelease\u002F$(",[81,4632,4530],{"class":87},[81,4634,4635],{"class":91}," -L",[81,4637,2149],{"class":91},[81,4639,4640],{"class":101}," https:\u002F\u002Fdl.k8s.io\u002Frelease\u002Fstable.txt)\u002Fbin\u002Flinux\u002Famd64\u002Fkubectl\"\n",[81,4642,4643,4645,4647,4649,4651,4653,4655],{"class":83,"line":95},[81,4644,4530],{"class":87},[81,4646,4627],{"class":91},[81,4648,4630],{"class":101},[81,4650,4530],{"class":87},[81,4652,4635],{"class":91},[81,4654,2149],{"class":91},[81,4656,4657],{"class":101}," https:\u002F\u002Fdl.k8s.io\u002Frelease\u002Fstable.txt)\u002Fbin\u002Flinux\u002Famd64\u002Fkubectl.sha256\"\n",[81,4659,4660,4663,4666,4668,4671,4673,4676],{"class":83,"line":319},[81,4661,4662],{"class":91},"echo",[81,4664,4665],{"class":101}," \"$(",[81,4667,2130],{"class":87},[81,4669,4670],{"class":101}," kubectl.sha256)  kubectl\"",[81,4672,4540],{"class":4539},[81,4674,4675],{"class":87}," sha256sum",[81,4677,4678],{"class":91}," --check\n",[81,4680,4681,4683,4686,4689,4692,4695,4697,4700,4703,4706],{"class":83,"line":328},[81,4682,1231],{"class":87},[81,4684,4685],{"class":101}," install",[81,4687,4688],{"class":91}," -o",[81,4690,4691],{"class":101}," root",[81,4693,4694],{"class":91}," -g",[81,4696,4691],{"class":101},[81,4698,4699],{"class":91}," -m",[81,4701,4702],{"class":91}," 0755",[81,4704,4705],{"class":101}," kubectl",[81,4707,4708],{"class":101}," \u002Fusr\u002Flocal\u002Fbin\u002Fkubectl\n",[24,4710,4711,4712],{},"Check version\n",[71,4713,4715],{"className":73,"code":4714,"language":75,"meta":76,"style":76},"kubectl version\n",[78,4716,4717],{"__ignoreMap":76},[81,4718,4719,4722],{"class":83,"line":84},[81,4720,4721],{"class":87},"kubectl",[81,4723,4724],{"class":101}," version\n",[63,4726,4728],{"id":4727},"_3-helm","3. Helm",[21,4730,4731,4749],{},[24,4732,4520,4733],{},[71,4734,4736],{"className":73,"code":4735,"language":75,"meta":76,"style":76},"curl https:\u002F\u002Fraw.githubusercontent.com\u002Fhelm\u002Fhelm\u002Fmain\u002Fscripts\u002Fget-helm-3 | bash\n",[78,4737,4738],{"__ignoreMap":76},[81,4739,4740,4742,4745,4747],{"class":83,"line":84},[81,4741,4530],{"class":87},[81,4743,4744],{"class":101}," https:\u002F\u002Fraw.githubusercontent.com\u002Fhelm\u002Fhelm\u002Fmain\u002Fscripts\u002Fget-helm-3",[81,4746,4540],{"class":4539},[81,4748,2121],{"class":87},[24,4750,4711,4751],{},[71,4752,4754],{"className":73,"code":4753,"language":75,"meta":76,"style":76},"helm version\n",[78,4755,4756],{"__ignoreMap":76},[81,4757,4758,4761],{"class":83,"line":84},[81,4759,4760],{"class":87},"helm",[81,4762,4724],{"class":101},[63,4764,4766],{"id":4765},"_4-kind","4. Kind",[21,4768,4769,4871],{},[24,4770,4520,4771],{},[71,4772,4774],{"className":73,"code":4773,"language":75,"meta":76,"style":76},"# For AMD64 \u002F x86_64\n[ $(uname -m) = x86_64 ] && curl -Lo .\u002Fkind https:\u002F\u002Fkind.sigs.k8s.io\u002Fdl\u002Fv0.29.0\u002Fkind-linux-amd64\n\n# For ARM64\n[ $(uname -m) = aarch64 ] && curl -Lo .\u002Fkind https:\u002F\u002Fkind.sigs.k8s.io\u002Fdl\u002Fv0.29.0\u002Fkind-linux-arm64\n\nchmod +x .\u002Fkind\nsudo mv .\u002Fkind \u002Fusr\u002Flocal\u002Fbin\u002Fkind\n",[78,4775,4776,4782,4811,4815,4820,4844,4848,4859],{"__ignoreMap":76},[81,4777,4778],{"class":83,"line":84},[81,4779,4781],{"class":4780},"sAwPA","# For AMD64 \u002F x86_64\n",[81,4783,4784,4787,4790,4792,4795,4797,4800,4802,4805,4808],{"class":83,"line":95},[81,4785,4786],{"class":859},"[ $(",[81,4788,4789],{"class":87},"uname",[81,4791,4699],{"class":91},[81,4793,4794],{"class":859},") ",[81,4796,2385],{"class":4539},[81,4798,4799],{"class":859}," x86_64 ] && ",[81,4801,4530],{"class":87},[81,4803,4804],{"class":91}," -Lo",[81,4806,4807],{"class":101}," .\u002Fkind",[81,4809,4810],{"class":101}," https:\u002F\u002Fkind.sigs.k8s.io\u002Fdl\u002Fv0.29.0\u002Fkind-linux-amd64\n",[81,4812,4813],{"class":83,"line":319},[81,4814,978],{"emptyLinePlaceholder":977},[81,4816,4817],{"class":83,"line":328},[81,4818,4819],{"class":4780},"# For ARM64\n",[81,4821,4822,4824,4826,4828,4830,4832,4835,4837,4839,4841],{"class":83,"line":891},[81,4823,4786],{"class":859},[81,4825,4789],{"class":87},[81,4827,4699],{"class":91},[81,4829,4794],{"class":859},[81,4831,2385],{"class":4539},[81,4833,4834],{"class":859}," aarch64 ] && ",[81,4836,4530],{"class":87},[81,4838,4804],{"class":91},[81,4840,4807],{"class":101},[81,4842,4843],{"class":101}," https:\u002F\u002Fkind.sigs.k8s.io\u002Fdl\u002Fv0.29.0\u002Fkind-linux-arm64\n",[81,4845,4846],{"class":83,"line":899},[81,4847,978],{"emptyLinePlaceholder":977},[81,4849,4850,4853,4856],{"class":83,"line":910},[81,4851,4852],{"class":87},"chmod",[81,4854,4855],{"class":101}," +x",[81,4857,4858],{"class":101}," .\u002Fkind\n",[81,4860,4861,4863,4866,4868],{"class":83,"line":921},[81,4862,1231],{"class":87},[81,4864,4865],{"class":101}," mv",[81,4867,4807],{"class":101},[81,4869,4870],{"class":101}," \u002Fusr\u002Flocal\u002Fbin\u002Fkind\n",[24,4872,4711,4873],{},[71,4874,4876],{"className":73,"code":4875,"language":75,"meta":76,"style":76},"kind version\n",[78,4877,4878],{"__ignoreMap":76},[81,4879,4880,4882],{"class":83,"line":84},[81,4881,4504],{"class":87},[81,4883,4724],{"class":101},[11,4885,4886],{},"Now we have everything installed on our system for cluster setup.",[11,4888,4889,4890,4893,4894,4897],{},"Let's create a k8s cluster which will have ",[78,4891,4892],{},"1 Master"," and ",[78,4895,4896],{},"2 Worker"," node",[339,4899,4900],{},[24,4901,4902,4903,4906],{},"Create a ",[78,4904,4905],{},"kind-config.yaml"," file and copy paste the below content",[71,4908,4910],{"className":846,"code":4909,"language":848,"meta":76,"style":76},"kind: Cluster\napiVersion: kind.x-k8s.io\u002Fv1alpha4\nnodes:\n- role: control-plane\n  extraPortMappings:\n      - containerPort: 30080\n        hostPort: 30080   # Map container's port 30080 to host's port 30080\n        protocol: TCP\n      - containerPort: 30443\n        hostPort: 30443  # Map container's port 30443 to host's port 30443\n        protocol: TCP\n- role: worker\n- role: worker\n",[78,4911,4912,4921,4931,4938,4951,4958,4970,4983,4993,5004,5016,5024,5035],{"__ignoreMap":76},[81,4913,4914,4916,4918],{"class":83,"line":84},[81,4915,4504],{"class":855},[81,4917,860],{"class":859},[81,4919,4920],{"class":101},"Cluster\n",[81,4922,4923,4926,4928],{"class":83,"line":95},[81,4924,4925],{"class":855},"apiVersion",[81,4927,860],{"class":859},[81,4929,4930],{"class":101},"kind.x-k8s.io\u002Fv1alpha4\n",[81,4932,4933,4936],{"class":83,"line":319},[81,4934,4935],{"class":855},"nodes",[81,4937,871],{"class":859},[81,4939,4940,4943,4946,4948],{"class":83,"line":328},[81,4941,4942],{"class":859},"- ",[81,4944,4945],{"class":855},"role",[81,4947,860],{"class":859},[81,4949,4950],{"class":101},"control-plane\n",[81,4952,4953,4956],{"class":83,"line":891},[81,4954,4955],{"class":855},"  extraPortMappings",[81,4957,871],{"class":859},[81,4959,4960,4962,4965,4967],{"class":83,"line":899},[81,4961,953],{"class":859},[81,4963,4964],{"class":855},"containerPort",[81,4966,860],{"class":859},[81,4968,4969],{"class":91},"30080\n",[81,4971,4972,4975,4977,4980],{"class":83,"line":910},[81,4973,4974],{"class":855},"        hostPort",[81,4976,860],{"class":859},[81,4978,4979],{"class":91},"30080",[81,4981,4982],{"class":4780},"   # Map container's port 30080 to host's port 30080\n",[81,4984,4985,4988,4990],{"class":83,"line":921},[81,4986,4987],{"class":855},"        protocol",[81,4989,860],{"class":859},[81,4991,4992],{"class":101},"TCP\n",[81,4994,4995,4997,4999,5001],{"class":83,"line":931},[81,4996,953],{"class":859},[81,4998,4964],{"class":855},[81,5000,860],{"class":859},[81,5002,5003],{"class":91},"30443\n",[81,5005,5006,5008,5010,5013],{"class":83,"line":942},[81,5007,4974],{"class":855},[81,5009,860],{"class":859},[81,5011,5012],{"class":91},"30443",[81,5014,5015],{"class":4780},"  # Map container's port 30443 to host's port 30443\n",[81,5017,5018,5020,5022],{"class":83,"line":950},[81,5019,4987],{"class":855},[81,5021,860],{"class":859},[81,5023,4992],{"class":101},[81,5025,5026,5028,5030,5032],{"class":83,"line":959},[81,5027,4942],{"class":859},[81,5029,4945],{"class":855},[81,5031,860],{"class":859},[81,5033,5034],{"class":101},"worker\n",[81,5036,5037,5039,5041,5043],{"class":83,"line":967},[81,5038,4942],{"class":859},[81,5040,4945],{"class":855},[81,5042,860],{"class":859},[81,5044,5034],{"class":101},[339,5046,5047],{"start":95},[24,5048,5049],{},"Run below command to create cluster",[71,5051,5053],{"className":73,"code":5052,"language":75,"meta":76,"style":76},"kind create cluster --config kind-config.yaml\n",[78,5054,5055],{"__ignoreMap":76},[81,5056,5057,5059,5062,5065,5068],{"class":83,"line":84},[81,5058,4504],{"class":87},[81,5060,5061],{"class":101}," create",[81,5063,5064],{"class":101}," cluster",[81,5066,5067],{"class":91}," --config",[81,5069,5070],{"class":101}," kind-config.yaml\n",[339,5072,5073],{"start":319},[24,5074,5075],{},"Check nodes",[71,5077,5079],{"className":73,"code":5078,"language":75,"meta":76,"style":76},"kubectl get nodes\n",[78,5080,5081],{"__ignoreMap":76},[81,5082,5083,5085,5088],{"class":83,"line":84},[81,5084,4721],{"class":87},[81,5086,5087],{"class":101}," get",[81,5089,5090],{"class":101}," nodes\n",[11,5092,5093],{},"Output:",[71,5095,5097],{"className":73,"code":5096,"language":75,"meta":76,"style":76},"NAME                 STATUS   ROLES           AGE   VERSION\nkind-control-plane   Ready    control-plane   21m   v1.33.1\nkind-worker          Ready    \u003Cnone>          21m   v1.33.1\nkind-worker2         Ready    \u003Cnone>          21m   v1.33.1\n",[78,5098,5099,5116,5133,5157],{"__ignoreMap":76},[81,5100,5101,5104,5107,5110,5113],{"class":83,"line":84},[81,5102,5103],{"class":87},"NAME",[81,5105,5106],{"class":101},"                 STATUS",[81,5108,5109],{"class":101},"   ROLES",[81,5111,5112],{"class":101},"           AGE",[81,5114,5115],{"class":101},"   VERSION\n",[81,5117,5118,5121,5124,5127,5130],{"class":83,"line":95},[81,5119,5120],{"class":87},"kind-control-plane",[81,5122,5123],{"class":101},"   Ready",[81,5125,5126],{"class":101},"    control-plane",[81,5128,5129],{"class":101},"   21m",[81,5131,5132],{"class":101},"   v1.33.1\n",[81,5134,5135,5138,5141,5143,5146,5149,5152,5155],{"class":83,"line":319},[81,5136,5137],{"class":87},"kind-worker",[81,5139,5140],{"class":101},"          Ready",[81,5142,2404],{"class":4539},[81,5144,5145],{"class":101},"non",[81,5147,5148],{"class":859},"e",[81,5150,5151],{"class":4539},">",[81,5153,5154],{"class":101},"          21m",[81,5156,5132],{"class":101},[81,5158,5159,5162,5165,5167,5169,5171,5173,5175],{"class":83,"line":328},[81,5160,5161],{"class":87},"kind-worker2",[81,5163,5164],{"class":101},"         Ready",[81,5166,2404],{"class":4539},[81,5168,5145],{"class":101},[81,5170,5148],{"class":859},[81,5172,5151],{"class":4539},[81,5174,5154],{"class":101},[81,5176,5132],{"class":101},[4240,5178],{},[44,5180,5182],{"id":5181},"important-k8s-concepts","Important K8s Concepts",[63,5184,5186],{"id":5185},"_1-pods-and-deployments","1. Pods and Deployments",[21,5188,5189,5192,5195,5212,5388,5409,5476,5507,5536,5562,5587,5607,5625],{},[24,5190,5191],{},"A Pod is the smallest unit in Kubernetes. It runs one or more containers with shared storage and network resources.",[24,5193,5194],{},"A Deployment ensures that the desired number of pod replicas are running and manages rolling updates.",[24,5196,5197,5198],{},"We can list the running pods via following command\n",[71,5199,5201],{"className":73,"code":5200,"language":75,"meta":76,"style":76},"kubectl get pods\n",[78,5202,5203],{"__ignoreMap":76},[81,5204,5205,5207,5209],{"class":83,"line":84},[81,5206,4721],{"class":87},[81,5208,5087],{"class":101},[81,5210,5211],{"class":101}," pods\n",[24,5213,5214,5215,308,5218],{},"Let's create a our first pod using deployment file ",[78,5216,5217],{},"nginx-deployment.yaml",[71,5219,5221],{"className":846,"code":5220,"language":848,"meta":76,"style":76},"# nginx-deployment.yaml\napiVersion: apps\u002Fv1\nkind: Deployment\nmetadata:\n  name: nginx-deployment\nspec:\n  replicas: 2\n  selector:\n    matchLabels:\n      app: nginx\n  template:\n    metadata:\n      labels:\n        app: nginx\n    spec:\n      containers:\n      - name: nginx\n        image: nginx:latest\n        ports:\n        - containerPort: 80\n",[78,5222,5223,5228,5237,5246,5253,5263,5270,5280,5287,5294,5304,5311,5318,5325,5334,5341,5348,5359,5369,5376],{"__ignoreMap":76},[81,5224,5225],{"class":83,"line":84},[81,5226,5227],{"class":4780},"# nginx-deployment.yaml\n",[81,5229,5230,5232,5234],{"class":83,"line":95},[81,5231,4925],{"class":855},[81,5233,860],{"class":859},[81,5235,5236],{"class":101},"apps\u002Fv1\n",[81,5238,5239,5241,5243],{"class":83,"line":319},[81,5240,4504],{"class":855},[81,5242,860],{"class":859},[81,5244,5245],{"class":101},"Deployment\n",[81,5247,5248,5251],{"class":83,"line":328},[81,5249,5250],{"class":855},"metadata",[81,5252,871],{"class":859},[81,5254,5255,5258,5260],{"class":83,"line":891},[81,5256,5257],{"class":855},"  name",[81,5259,860],{"class":859},[81,5261,5262],{"class":101},"nginx-deployment\n",[81,5264,5265,5268],{"class":83,"line":899},[81,5266,5267],{"class":855},"spec",[81,5269,871],{"class":859},[81,5271,5272,5275,5277],{"class":83,"line":910},[81,5273,5274],{"class":855},"  replicas",[81,5276,860],{"class":859},[81,5278,5279],{"class":91},"2\n",[81,5281,5282,5285],{"class":83,"line":921},[81,5283,5284],{"class":855},"  selector",[81,5286,871],{"class":859},[81,5288,5289,5292],{"class":83,"line":931},[81,5290,5291],{"class":855},"    matchLabels",[81,5293,871],{"class":859},[81,5295,5296,5299,5301],{"class":83,"line":942},[81,5297,5298],{"class":855},"      app",[81,5300,860],{"class":859},[81,5302,5303],{"class":101},"nginx\n",[81,5305,5306,5309],{"class":83,"line":950},[81,5307,5308],{"class":855},"  template",[81,5310,871],{"class":859},[81,5312,5313,5316],{"class":83,"line":959},[81,5314,5315],{"class":855},"    metadata",[81,5317,871],{"class":859},[81,5319,5320,5323],{"class":83,"line":967},[81,5321,5322],{"class":855},"      labels",[81,5324,871],{"class":859},[81,5326,5327,5330,5332],{"class":83,"line":974},[81,5328,5329],{"class":855},"        app",[81,5331,860],{"class":859},[81,5333,5303],{"class":101},[81,5335,5336,5339],{"class":83,"line":981},[81,5337,5338],{"class":855},"    spec",[81,5340,871],{"class":859},[81,5342,5343,5346],{"class":83,"line":989},[81,5344,5345],{"class":855},"      containers",[81,5347,871],{"class":859},[81,5349,5350,5352,5355,5357],{"class":83,"line":999},[81,5351,953],{"class":859},[81,5353,5354],{"class":855},"name",[81,5356,860],{"class":859},[81,5358,5303],{"class":101},[81,5360,5361,5364,5366],{"class":83,"line":1006},[81,5362,5363],{"class":855},"        image",[81,5365,860],{"class":859},[81,5367,5368],{"class":101},"nginx:latest\n",[81,5370,5371,5374],{"class":83,"line":1017},[81,5372,5373],{"class":855},"        ports",[81,5375,871],{"class":859},[81,5377,5378,5381,5383,5385],{"class":83,"line":1028},[81,5379,5380],{"class":859},"        - ",[81,5382,4964],{"class":855},[81,5384,860],{"class":859},[81,5386,5387],{"class":91},"80\n",[24,5389,5390,5391],{},"Apply the deployment file\n",[71,5392,5394],{"className":73,"code":5393,"language":75,"meta":76,"style":76},"kubectl apply -f nginx-deployment.yaml\n",[78,5395,5396],{"__ignoreMap":76},[81,5397,5398,5400,5403,5406],{"class":83,"line":84},[81,5399,4721],{"class":87},[81,5401,5402],{"class":101}," apply",[81,5404,5405],{"class":91}," -f",[81,5407,5408],{"class":101}," nginx-deployment.yaml\n",[24,5410,5411,5412,5424,5425],{},"Now list the running pods\n",[71,5413,5414],{"className":73,"code":5200,"language":75,"meta":76,"style":76},[78,5415,5416],{"__ignoreMap":76},[81,5417,5418,5420,5422],{"class":83,"line":84},[81,5419,4721],{"class":87},[81,5421,5087],{"class":101},[81,5423,5211],{"class":101},"\nOutput:\n",[71,5426,5428],{"className":73,"code":5427,"language":75,"meta":76,"style":76},"NAME                              READY   STATUS    RESTARTS   AGE\nnginx-deployment-96b9d695-9h49b   1\u002F1     Running   0          20m\nnginx-deployment-96b9d695-rhd8x   1\u002F1     Running   0          20m\n",[78,5429,5430,5446,5463],{"__ignoreMap":76},[81,5431,5432,5434,5437,5440,5443],{"class":83,"line":84},[81,5433,5103],{"class":87},[81,5435,5436],{"class":101},"                              READY",[81,5438,5439],{"class":101},"   STATUS",[81,5441,5442],{"class":101},"    RESTARTS",[81,5444,5445],{"class":101},"   AGE\n",[81,5447,5448,5451,5454,5457,5460],{"class":83,"line":95},[81,5449,5450],{"class":87},"nginx-deployment-96b9d695-9h49b",[81,5452,5453],{"class":101},"   1\u002F1",[81,5455,5456],{"class":101},"     Running",[81,5458,5459],{"class":91},"   0",[81,5461,5462],{"class":101},"          20m\n",[81,5464,5465,5468,5470,5472,5474],{"class":83,"line":319},[81,5466,5467],{"class":87},"nginx-deployment-96b9d695-rhd8x",[81,5469,5453],{"class":101},[81,5471,5456],{"class":101},[81,5473,5459],{"class":91},[81,5475,5462],{"class":101},[24,5477,5478,5479],{},"We can exec into the pods using the below command to view the files of our container\n",[71,5480,5482],{"className":73,"code":5481,"language":75,"meta":76,"style":76},"kubectl exec -it \u003Cpod-name> -- sh\n",[78,5483,5484],{"__ignoreMap":76},[81,5485,5486,5488,5490,5492,5495,5498,5500,5502,5505],{"class":83,"line":84},[81,5487,4721],{"class":87},[81,5489,1206],{"class":101},[81,5491,2116],{"class":91},[81,5493,5494],{"class":4539}," \u003C",[81,5496,5497],{"class":101},"pod-nam",[81,5499,5148],{"class":859},[81,5501,5151],{"class":4539},[81,5503,5504],{"class":91}," --",[81,5506,4543],{"class":101},[24,5508,5509,5510,5513],{},"We can also view the logs of the container which process prints on ",[78,5511,5512],{},"stdout",[71,5514,5516],{"className":73,"code":5515,"language":75,"meta":76,"style":76},"kubectl logs -f \u003Ccontainer-name>\n",[78,5517,5518],{"__ignoreMap":76},[81,5519,5520,5522,5525,5527,5529,5532,5534],{"class":83,"line":84},[81,5521,4721],{"class":87},[81,5523,5524],{"class":101}," logs",[81,5526,5405],{"class":91},[81,5528,5494],{"class":4539},[81,5530,5531],{"class":101},"container-nam",[81,5533,5148],{"class":859},[81,5535,2372],{"class":4539},[24,5537,5538,5539],{},"We can describe the pod to view each and every detail of it. if pod crashes or fails to start here we can debug the reason.\n",[71,5540,5542],{"className":73,"code":5541,"language":75,"meta":76,"style":76},"kubectl describe pod\u002F\u003Cpod-name>\n",[78,5543,5544],{"__ignoreMap":76},[81,5545,5546,5548,5551,5554,5556,5558,5560],{"class":83,"line":84},[81,5547,4721],{"class":87},[81,5549,5550],{"class":101}," describe",[81,5552,5553],{"class":101}," pod\u002F",[81,5555,2377],{"class":4539},[81,5557,5497],{"class":101},[81,5559,5148],{"class":859},[81,5561,2372],{"class":4539},[24,5563,5564,5565],{},"To delete the pods if we run the below command.The existing pod will delete but new pod will be created by control manager using existing deployment resource which we applied previously.\n",[71,5566,5568],{"className":73,"code":5567,"language":75,"meta":76,"style":76},"kubectl delete pod\u002F\u003Cpod-name>\n",[78,5569,5570],{"__ignoreMap":76},[81,5571,5572,5574,5577,5579,5581,5583,5585],{"class":83,"line":84},[81,5573,4721],{"class":87},[81,5575,5576],{"class":101}," delete",[81,5578,5553],{"class":101},[81,5580,2377],{"class":4539},[81,5582,5497],{"class":101},[81,5584,5148],{"class":859},[81,5586,2372],{"class":4539},[24,5588,5589,5590],{},"If we want to delete the pods permanently then we should delete the deployment and pod will be removed by k8s\n",[71,5591,5593],{"className":73,"code":5592,"language":75,"meta":76,"style":76},"kubectl delete deployment nginx-deployment\n",[78,5594,5595],{"__ignoreMap":76},[81,5596,5597,5599,5601,5604],{"class":83,"line":84},[81,5598,4721],{"class":87},[81,5600,5576],{"class":101},[81,5602,5603],{"class":101}," deployment",[81,5605,5606],{"class":101}," nginx-deployment\n",[24,5608,5609,5610],{},"We can also delete K8s deployment resource using our existing deployment file\n",[71,5611,5613],{"className":73,"code":5612,"language":75,"meta":76,"style":76},"kubectl delete -f nginx-deployment.yaml\n",[78,5614,5615],{"__ignoreMap":76},[81,5616,5617,5619,5621,5623],{"class":83,"line":84},[81,5618,4721],{"class":87},[81,5620,5576],{"class":101},[81,5622,5405],{"class":91},[81,5624,5408],{"class":101},[24,5626,5627,5628],{},"Wants to read more about pods checkout the ",[1566,5629,5632],{"href":5630,"rel":5631},"https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fconcepts\u002Fworkloads\u002Fpods",[1570],"K8s Pod documentation",[63,5634,5636],{"id":5635},"_2-services","2. Services",[21,5638,5639,5644,5647,5650,5653,5676,5679,5796,5815,5917,5926],{},[24,5640,5641,5642,1187],{},"Each pod in a cluster gets its own unique cluster-wide IP address. A pod has its own private network namespace which is shared by all of the containers within the pod. Processes running in different containers in the same pod can communicate with each other over ",[78,5643,2076],{},[24,5645,5646],{},"The pod network (also called a cluster network) handles communication between pods. It ensures that all pods can communicate with all other pods, whether they are on the same node or on different nodes.",[24,5648,5649],{},"If we use a Deployment to run our app, that Deployment can create and destroy Pods dynamically. From one moment to the next, we don't know how many of those Pods are working and healthy. we might not even know what those healthy Pods are named.",[24,5651,5652],{},"The Service API lets us provide a stable (long lived) IP address or hostname for a service implemented by one or more backend pods, where the individual pods making up the service can change over time.",[24,5654,5655,5656],{},"A Service exposes pods to internal or external traffic. So we have several types of services:\n",[21,5657,5658,5664,5670],{},[24,5659,5660,5663],{},[149,5661,5662],{},"ClusterIP"," : This is a default service type. it exposes service on cluster's internal ip and makes it reachable only from within the cluster.",[24,5665,5666,5669],{},[149,5667,5668],{},"NodePort"," : Exposes service on each Node's IP at a static port(the NodePort). The default range of NodePort is 30000–32767 .",[24,5671,5672,5675],{},[149,5673,5674],{},"LoadBalancer"," : Exposes the Service externally using an external load balancer.",[24,5677,5678],{},"Let's access our nginx pod from outside of the cluster using NodePort service.",[24,5680,4902,5681,5684,5685],{},[78,5682,5683],{},"nginx-service.yaml"," file and copy paste the below content.\n",[71,5686,5688],{"className":846,"code":5687,"language":848,"meta":76,"style":76},"# nginx-service.yaml\napiVersion: v1\nkind: Service\nmetadata:\n  name: nginx-service\nspec:\n  type: NodePort\n  selector:\n    app: nginx\n  ports:\n    - port: 80\n      targetPort: 80\n      nodePort: 30080\n",[78,5689,5690,5695,5704,5713,5719,5728,5734,5744,5750,5759,5766,5778,5787],{"__ignoreMap":76},[81,5691,5692],{"class":83,"line":84},[81,5693,5694],{"class":4780},"# nginx-service.yaml\n",[81,5696,5697,5699,5701],{"class":83,"line":95},[81,5698,4925],{"class":855},[81,5700,860],{"class":859},[81,5702,5703],{"class":101},"v1\n",[81,5705,5706,5708,5710],{"class":83,"line":319},[81,5707,4504],{"class":855},[81,5709,860],{"class":859},[81,5711,5712],{"class":101},"Service\n",[81,5714,5715,5717],{"class":83,"line":328},[81,5716,5250],{"class":855},[81,5718,871],{"class":859},[81,5720,5721,5723,5725],{"class":83,"line":891},[81,5722,5257],{"class":855},[81,5724,860],{"class":859},[81,5726,5727],{"class":101},"nginx-service\n",[81,5729,5730,5732],{"class":83,"line":899},[81,5731,5267],{"class":855},[81,5733,871],{"class":859},[81,5735,5736,5739,5741],{"class":83,"line":910},[81,5737,5738],{"class":855},"  type",[81,5740,860],{"class":859},[81,5742,5743],{"class":101},"NodePort\n",[81,5745,5746,5748],{"class":83,"line":921},[81,5747,5284],{"class":855},[81,5749,871],{"class":859},[81,5751,5752,5755,5757],{"class":83,"line":931},[81,5753,5754],{"class":855},"    app",[81,5756,860],{"class":859},[81,5758,5303],{"class":101},[81,5760,5761,5764],{"class":83,"line":942},[81,5762,5763],{"class":855},"  ports",[81,5765,871],{"class":859},[81,5767,5768,5771,5774,5776],{"class":83,"line":950},[81,5769,5770],{"class":859},"    - ",[81,5772,5773],{"class":855},"port",[81,5775,860],{"class":859},[81,5777,5387],{"class":91},[81,5779,5780,5783,5785],{"class":83,"line":959},[81,5781,5782],{"class":855},"      targetPort",[81,5784,860],{"class":859},[81,5786,5387],{"class":91},[81,5788,5789,5792,5794],{"class":83,"line":967},[81,5790,5791],{"class":855},"      nodePort",[81,5793,860],{"class":859},[81,5795,4969],{"class":91},[24,5797,5798,5799],{},"Let's apply the service manifest using below command.\n",[71,5800,5802],{"className":73,"code":5801,"language":75,"meta":76,"style":76},"kubectl apply -f nginx-service.yaml\n",[78,5803,5804],{"__ignoreMap":76},[81,5805,5806,5808,5810,5812],{"class":83,"line":84},[81,5807,4721],{"class":87},[81,5809,5402],{"class":101},[81,5811,5405],{"class":91},[81,5813,5814],{"class":101}," nginx-service.yaml\n",[24,5816,5817,5818,5424,5832],{},"To list the services run the below command\n",[71,5819,5821],{"className":73,"code":5820,"language":75,"meta":76,"style":76},"kubectl get services\n",[78,5822,5823],{"__ignoreMap":76},[81,5824,5825,5827,5829],{"class":83,"line":84},[81,5826,4721],{"class":87},[81,5828,5087],{"class":101},[81,5830,5831],{"class":101}," services\n",[71,5833,5835],{"className":73,"code":5834,"language":75,"meta":76,"style":76},"NAME            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE\nkubernetes      ClusterIP   10.96.0.1       \u003Cnone>        443\u002FTCP        49s\nnginx-service   NodePort    10.96.165.229   \u003Cnone>        80:30080\u002FTCP   8s\n",[78,5836,5837,5865,5891],{"__ignoreMap":76},[81,5838,5839,5841,5844,5847,5850,5853,5856,5859,5862],{"class":83,"line":84},[81,5840,5103],{"class":87},[81,5842,5843],{"class":101},"            TYPE",[81,5845,5846],{"class":101},"        CLUSTER-IP",[81,5848,5849],{"class":101},"      EXTERNAL-IP",[81,5851,5852],{"class":101},"   PORT",[81,5854,5855],{"class":859},"(",[81,5857,5858],{"class":87},"S",[81,5860,5861],{"class":859},")        ",[81,5863,5864],{"class":101},"AGE\n",[81,5866,5867,5870,5873,5876,5879,5881,5883,5885,5888],{"class":83,"line":95},[81,5868,5869],{"class":87},"kubernetes",[81,5871,5872],{"class":101},"      ClusterIP",[81,5874,5875],{"class":91},"   10.96.0.1",[81,5877,5878],{"class":4539},"       \u003C",[81,5880,5145],{"class":101},[81,5882,5148],{"class":859},[81,5884,5151],{"class":4539},[81,5886,5887],{"class":101},"        443\u002FTCP",[81,5889,5890],{"class":101},"        49s\n",[81,5892,5893,5896,5899,5902,5905,5907,5909,5911,5914],{"class":83,"line":319},[81,5894,5895],{"class":87},"nginx-service",[81,5897,5898],{"class":101},"   NodePort",[81,5900,5901],{"class":91},"    10.96.165.229",[81,5903,5904],{"class":4539},"   \u003C",[81,5906,5145],{"class":101},[81,5908,5148],{"class":859},[81,5910,5151],{"class":4539},[81,5912,5913],{"class":101},"        80:30080\u002FTCP",[81,5915,5916],{"class":101},"   8s\n",[24,5918,5919,5920,5925],{},"Now if we open the ",[1566,5921,5924],{"href":5922,"rel":5923},"http:\u002F\u002Flocalhost:30080",[1570],"localhost:30080"," in our browser. we will see a page served by our nginx pod.",[24,5927,5928,5929],{},"Wants to read more about k8s network model checkout the ",[1566,5930,5933],{"href":5931,"rel":5932},"https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fconcepts\u002Fservices-networking",[1570],"K8s services documentation",[63,5935,5937],{"id":5936},"_3-namespaces","3. Namespaces",[21,5939,5940,5943,5946,5949,6022,6025,6066,6096],{},[24,5941,5942],{},"Namespaces provide a mechanism for isolating groups of resources within a single cluster.",[24,5944,5945],{},"Names of resources need to be unique within a namespace, but not across namespaces.",[24,5947,5948],{},"Namespaces cannot be nested inside one another and each Kubernetes resource can only be in one namespace.",[24,5950,5951,5952,5966,5093,5969],{},"Kubernetes starts with four initial namespaces. We can list the current namespaces in a cluster using below command.",[71,5953,5955],{"className":73,"code":5954,"language":75,"meta":76,"style":76},"kubectl get namespaces\n",[78,5956,5957],{"__ignoreMap":76},[81,5958,5959,5961,5963],{"class":83,"line":84},[81,5960,4721],{"class":87},[81,5962,5087],{"class":101},[81,5964,5965],{"class":101}," namespaces\n",[5967,5968],"br",{},[71,5970,5972],{"className":73,"code":5971,"language":75,"meta":76,"style":76},"NAME                 STATUS   AGE\ndefault              Active   78m\nkube-node-lease      Active   78m\nkube-public          Active   78m\nkube-system          Active   78m\n",[78,5973,5974,5982,5993,6003,6013],{"__ignoreMap":76},[81,5975,5976,5978,5980],{"class":83,"line":84},[81,5977,5103],{"class":87},[81,5979,5106],{"class":101},[81,5981,5445],{"class":101},[81,5983,5984,5987,5990],{"class":83,"line":95},[81,5985,5986],{"class":87},"default",[81,5988,5989],{"class":101},"              Active",[81,5991,5992],{"class":101},"   78m\n",[81,5994,5995,5998,6001],{"class":83,"line":319},[81,5996,5997],{"class":87},"kube-node-lease",[81,5999,6000],{"class":101},"      Active",[81,6002,5992],{"class":101},[81,6004,6005,6008,6011],{"class":83,"line":328},[81,6006,6007],{"class":87},"kube-public",[81,6009,6010],{"class":101},"          Active",[81,6012,5992],{"class":101},[81,6014,6015,6018,6020],{"class":83,"line":891},[81,6016,6017],{"class":87},"kube-system",[81,6019,6010],{"class":101},[81,6021,5992],{"class":101},[24,6023,6024],{},"Most Kubernetes resources (e.g. pods, services, replication controllers, and others) are in some namespaces. However namespace resources are not themselves in a namespace. And low-level resources, such as nodes and persistentVolumes, are not in any namespace.",[24,6026,6027,6028],{},"To see which Kubernetes resources are and aren't in a namespace:",[71,6029,6031],{"className":73,"code":6030,"language":75,"meta":76,"style":76},"# In a namespace\nkubectl api-resources --namespaced=true\n\n# Not in a namespace\nkubectl api-resources --namespaced=false\n",[78,6032,6033,6038,6048,6052,6057],{"__ignoreMap":76},[81,6034,6035],{"class":83,"line":84},[81,6036,6037],{"class":4780},"# In a namespace\n",[81,6039,6040,6042,6045],{"class":83,"line":95},[81,6041,4721],{"class":87},[81,6043,6044],{"class":101}," api-resources",[81,6046,6047],{"class":91}," --namespaced=true\n",[81,6049,6050],{"class":83,"line":319},[81,6051,978],{"emptyLinePlaceholder":977},[81,6053,6054],{"class":83,"line":328},[81,6055,6056],{"class":4780},"# Not in a namespace\n",[81,6058,6059,6061,6063],{"class":83,"line":891},[81,6060,4721],{"class":87},[81,6062,6044],{"class":101},[81,6064,6065],{"class":91}," --namespaced=false\n",[24,6067,6068,6069,6072,6073,6075,6076],{},"To see all the resources of a particular namespace flag every command with ",[78,6070,6071],{},"-n \u003Cnamespace>"," such as to view running pods in ",[78,6074,6017],{}," it would be.",[71,6077,6079],{"className":73,"code":6078,"language":75,"meta":76,"style":76},"kubectl get pods -n kube-system\n",[78,6080,6081],{"__ignoreMap":76},[81,6082,6083,6085,6087,6090,6093],{"class":83,"line":84},[81,6084,4721],{"class":87},[81,6086,5087],{"class":101},[81,6088,6089],{"class":101}," pods",[81,6091,6092],{"class":91}," -n",[81,6094,6095],{"class":101}," kube-system\n",[24,6097,6098,6099],{},"Create a new namespace",[71,6100,6102],{"className":73,"code":6101,"language":75,"meta":76,"style":76},"kubectl create namespace mars\n",[78,6103,6104],{"__ignoreMap":76},[81,6105,6106,6108,6110,6113],{"class":83,"line":84},[81,6107,4721],{"class":87},[81,6109,5061],{"class":101},[81,6111,6112],{"class":101}," namespace",[81,6114,6115],{"class":101}," mars\n",[63,6117,6119],{"id":6118},"_4-configmaps-and-secrets","4. Configmaps and Secrets",[21,6121,6122,6125,6128,6131,6148,6156,6159,6162,6179],{},[24,6123,6124],{},"A ConfigMap is an API object used to store non-confidential data in key-value pairs.",[24,6126,6127],{},"Pods can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume.",[24,6129,6130],{},"A ConfigMap allows you to decouple environment-specific configuration from our container images, so that our applications are easily portable.",[24,6132,6133,6134],{},"List all configmaps\n",[71,6135,6137],{"className":73,"code":6136,"language":75,"meta":76,"style":76},"kubectl get configmaps\n",[78,6138,6139],{"__ignoreMap":76},[81,6140,6141,6143,6145],{"class":83,"line":84},[81,6142,4721],{"class":87},[81,6144,5087],{"class":101},[81,6146,6147],{"class":101}," configmaps\n",[24,6149,6150,6151],{},"To read more about configmaps and its usage please refere this ",[1566,6152,6155],{"href":6153,"rel":6154},"https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fconcepts\u002Fconfiguration\u002Fconfigmap\u002F",[1570],"k8s Configmap documentation",[24,6157,6158],{},"A Secret is an object that contains a small amount of sensitive data such as a password, a token, or a key.",[24,6160,6161],{},"Secrets are similar to ConfigMaps but are specifically intended to hold confidential data.",[24,6163,6164,6165],{},"List all secrets\n",[71,6166,6168],{"className":73,"code":6167,"language":75,"meta":76,"style":76},"kubectl get secrets\n",[78,6169,6170],{"__ignoreMap":76},[81,6171,6172,6174,6176],{"class":83,"line":84},[81,6173,4721],{"class":87},[81,6175,5087],{"class":101},[81,6177,6178],{"class":101}," secrets\n",[24,6180,6181,6182],{},"To read more about secrets and its usage please refer this ",[1566,6183,6186],{"href":6184,"rel":6185},"https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fconcepts\u002Fconfiguration\u002Fsecret",[1570],"k8s secrets documentation",[44,6188,6190],{"id":6189},"demo-of-kind-cluster-and-nginx-application","Demo of kind cluster and nginx application",[6192,6193],"iframe",{"width":6194,"height":6195,"src":6196,"frameBorder":6197,"allowFullScreen":977},"100%",400,"https:\u002F\u002Fwww.youtube.com\u002Fembed\u002F4dMUHRe6KBw","0",[44,6199,1560],{"id":1559},[21,6201,6202,6209,6216,6223,6230,6236,6243,6250],{},[24,6203,6204],{},[1566,6205,6208],{"href":6206,"rel":6207},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=s_o8dwzRlu4",[1570],"Kubernetes Crash Course for Absolute Beginners",[24,6210,6211],{},[1566,6212,6215],{"href":6213,"rel":6214},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=XuSQU5Grv1g&t=7676s",[1570],"Kubernetes Crash Course: Learn the Basics and Build a Microservice Application",[24,6217,6218],{},[1566,6219,6222],{"href":6220,"rel":6221},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=a-nWPre5QYI",[1570],"What is Kubernetes? | Kubernetes Explained",[24,6224,6225],{},[1566,6226,6229],{"href":6227,"rel":6228},"https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fhome\u002F",[1570],"Kubernetes Documentation",[24,6231,6232],{},[1566,6233,6235],{"href":6234},"\u002Fblogs\u002Fvirtualization_containers_and_role_of_docker_in_it","Virtualization , Containers and role of docker in it",[24,6237,6238],{},[1566,6239,6242],{"href":6240,"rel":6241},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=MDsjINTL7Ek&t=945s",[1570],"Below Kubernetes: Demystifying container runtimes",[24,6244,6245],{},[1566,6246,6249],{"href":6247,"rel":6248},"https:\u002F\u002Fyoutube.com\u002Fplaylist?list=PLl4APkPHzsUUOkOv3i62UidrLmSB8DcGC&si=F7r1nq72VJawqAOW",[1570],"Certified Kubernetes Administrator",[24,6251,6252],{},[1566,6253,6256],{"href":6254,"rel":6255},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=Mj04QOqAaJ8",[1570],"Understanding Kubernetes Networking in 30 Minutes",[44,6258,1617],{"id":1616},[11,6260,6261],{},"Till now we have just covered tip of the iceburg. We have alot to learn about kubernetes but the topics we have covered are just enough to get you started using k8s in local setup and explore its architecture.",[11,6263,6264],{},"For production grade cluster setup and k8s distributions we will talk in another blog. So stay tuned.",[11,6266,6267],{},"Thanks for sticking around and practicing!",[11,6269,6270],{},"Until next time happy coding!",[1631,6272,6273],{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .shJU0, html code.shiki .shJU0{--shiki-default:#22863A}",{"title":76,"searchDepth":95,"depth":95,"links":6275},[6276,6277,6281,6290,6297,6303,6304,6305],{"id":4071,"depth":95,"text":4072},{"id":4244,"depth":95,"text":4245,"children":6278},[6279,6280],{"id":4254,"depth":319,"text":4255},{"id":4266,"depth":319,"text":4267},{"id":4286,"depth":95,"text":4287,"children":6282},[6283,6284,6285,6286,6287,6288,6289],{"id":4293,"depth":319,"text":4294},{"id":4316,"depth":319,"text":4317},{"id":4349,"depth":319,"text":4350},{"id":4379,"depth":319,"text":4380},{"id":4401,"depth":319,"text":4402},{"id":4432,"depth":319,"text":4433},{"id":4462,"depth":319,"text":4463},{"id":4497,"depth":95,"text":4498,"children":6291},[6292,6294,6295,6296],{"id":4511,"depth":319,"text":6293},"1. Docker",{"id":4610,"depth":319,"text":4611},{"id":4727,"depth":319,"text":4728},{"id":4765,"depth":319,"text":4766},{"id":5181,"depth":95,"text":5182,"children":6298},[6299,6300,6301,6302],{"id":5185,"depth":319,"text":5186},{"id":5635,"depth":319,"text":5636},{"id":5936,"depth":319,"text":5937},{"id":6118,"depth":319,"text":6119},{"id":6189,"depth":95,"text":6190},{"id":1559,"depth":95,"text":1560},{"id":1616,"depth":95,"text":1617},"2025-06-07","A developer-friendly introduction to Kubernetes — pods, deployments, services, and namespaces explained with hands-on examples for getting started with K8s.",{},"\u002Fblogs\u002Fkubernetes",{"title":4042,"description":6307},"blogs\u002Fkubernetes\u002Findex",[2961,2962,2044,6313,5869,6314,6315],"containers","programming","software","6VemZpWvfRlCaF5WWnDY736MZXpTZQDZZk4wgdffDls",{"id":6318,"title":6319,"body":6320,"date":8462,"description":8463,"draft":1693,"extension":1694,"image":8464,"meta":8465,"navigation":977,"path":8466,"seo":8467,"stem":8468,"tags":8469,"__hash__":8472},"blogs\u002Fblogs\u002Fgolang-getting-started\u002Findex.md","Getting started with Golang",{"type":8,"value":6321,"toc":8447},[6322,6325,6331,6334,6345,6348,6351,6354,6359,6363,6489,6493,6648,6661,7104,7108,7118,7125,7128,7133,7171,7175,7178,7181,7200,7207,7321,7333,7337,7341,7348,7355,7360,7392,7395,7398,7455,7459,7469,7472,7535,7539,7542,7587,7594,7597,7672,7675,7747,7750,7757,7831,7833,7851,7855,7865,7917,7920,7980,7983,8034,8038,8051,8117,8121,8124,8185,8188,8304,8308,8322,8384,8395,8402,8405,8408,8411,8441,8444],[11,6323,6324],{},"Go is a simple, fast, and concurrent programming language. Its simplicity in design makes it an amazing programming language to work with. Go is currently gaining a lot of popularity, and a lot of organizations now prefer to write their backend in Go.",[11,6326,6327],{},[39,6328],{"alt":6329,"src":6330},"go logo","\u002Fimages\u002Fblogs\u002Fgolang-getting-started\u002Fgo-logo.png",[11,6332,6333],{},"Go was designed at Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson to improve programming productivity in an era of multicore, networked machines and large codebases.The designers wanted to address criticisms of other languages in use at Google, but keep their useful characteristics:",[21,6335,6336,6339,6342],{},[24,6337,6338],{},"Static typing and run-time efficiency (like C)",[24,6340,6341],{},"Readability and usability (like Python)",[24,6343,6344],{},"High-performance networking and multiprocessing",[11,6346,6347],{},"Its designers were primarily motivated by their shared dislike of C++.",[11,6349,6350],{},"Go was publicly announced in November 2009,and version 1.0 was released in March 2012. Go is widely used in production at Google and in many other organizations and open-source projects like Kubernetes, Prometheus, and Docker.",[11,6352,6353],{},"In retrospect the Go authors judged Go to be successful due to the overall engineering work around the language, including the runtime support for the language's concurrency feature.",[1874,6355,6356],{},[11,6357,6358],{},"Although the design of most languages concentrates on innovations in syntax, semantics, or typing, Go is focused on the software development process itself. The principal unusual property of the language itself—concurrency—addressed problems that arose with the proliferation of multicore CPUs in the 2010s. But more significant was the early work that established fundamentals for packaging, dependencies, build, test, deployment, and other workaday tasks of the software development world, aspects that are not usually foremost in language design.",[44,6360,6362],{"id":6361},"go-installation-for-linux","Go Installation for linux",[339,6364,6365,6373,6394,6421,6455],{},[24,6366,6367,6372],{},[1566,6368,6371],{"href":6369,"rel":6370},"https:\u002F\u002Fgo.dev\u002Fdoc\u002Finstall",[1570],"Download"," Binary",[24,6374,6375,6376],{},"Remove old go version (if any)\n",[71,6377,6379],{"className":73,"code":6378,"language":75,"meta":76,"style":76},"sudo rm -rf \u002Fusr\u002Flocal\u002Fgo\n",[78,6380,6381],{"__ignoreMap":76},[81,6382,6383,6385,6388,6391],{"class":83,"line":84},[81,6384,1231],{"class":87},[81,6386,6387],{"class":101}," rm",[81,6389,6390],{"class":91}," -rf",[81,6392,6393],{"class":101}," \u002Fusr\u002Flocal\u002Fgo\n",[24,6395,6396,6397],{},"Install go binary\n",[71,6398,6400],{"className":73,"code":6399,"language":75,"meta":76,"style":76},"sudo tar -C \u002Fusr\u002Flocal -xzf go1.24.2.linux-amd64.tar.gz\n",[78,6401,6402],{"__ignoreMap":76},[81,6403,6404,6406,6409,6412,6415,6418],{"class":83,"line":84},[81,6405,1231],{"class":87},[81,6407,6408],{"class":101}," tar",[81,6410,6411],{"class":91}," -C",[81,6413,6414],{"class":101}," \u002Fusr\u002Flocal",[81,6416,6417],{"class":91}," -xzf",[81,6419,6420],{"class":101}," go1.24.2.linux-amd64.tar.gz\n",[24,6422,6423,6424],{},"Add \u002Fusr\u002Flocal\u002Fgo\u002Fbin to the PATH environment variable\n",[71,6425,6427],{"className":73,"code":6426,"language":75,"meta":76,"style":76},"echo \"export PATH=$PATH:\u002Fusr\u002Flocal\u002Fgo\u002Fbin\" >> ~\u002F.bashrc\nsource ~\u002F.bashrc\n",[78,6428,6429,6448],{"__ignoreMap":76},[81,6430,6431,6433,6436,6439,6442,6445],{"class":83,"line":84},[81,6432,4662],{"class":91},[81,6434,6435],{"class":101}," \"export PATH=",[81,6437,6438],{"class":859},"$PATH",[81,6440,6441],{"class":101},":\u002Fusr\u002Flocal\u002Fgo\u002Fbin\"",[81,6443,6444],{"class":4539}," >>",[81,6446,6447],{"class":101}," ~\u002F.bashrc\n",[81,6449,6450,6453],{"class":83,"line":95},[81,6451,6452],{"class":91},"source",[81,6454,6447],{"class":101},[24,6456,6457,6458,6470,6471],{},"Verify installation\n",[71,6459,6461],{"className":73,"code":6460,"language":75,"meta":76,"style":76},"go version\n",[78,6462,6463],{"__ignoreMap":76},[81,6464,6465,6468],{"class":83,"line":84},[81,6466,6467],{"class":87},"go",[81,6469,4724],{"class":101},"\nOutputs:\n",[71,6472,6474],{"className":73,"code":6473,"language":75,"meta":76,"style":76},"go version go1.23.1 linux\u002Famd64\n",[78,6475,6476],{"__ignoreMap":76},[81,6477,6478,6480,6483,6486],{"class":83,"line":84},[81,6479,6467],{"class":87},[81,6481,6482],{"class":101}," version",[81,6484,6485],{"class":101}," go1.23.1",[81,6487,6488],{"class":101}," linux\u002Famd64\n",[44,6490,6492],{"id":6491},"lets-write-some-code","Let's write some code",[339,6494,6495,6517,6538,6618],{},[24,6496,6497,6498],{},"Make a directory\n",[71,6499,6501],{"className":73,"code":6500,"language":75,"meta":76,"style":76},"mkdir go-example\ncd go-example\n",[78,6502,6503,6511],{"__ignoreMap":76},[81,6504,6505,6508],{"class":83,"line":84},[81,6506,6507],{"class":87},"mkdir",[81,6509,6510],{"class":101}," go-example\n",[81,6512,6513,6515],{"class":83,"line":95},[81,6514,2618],{"class":91},[81,6516,6510],{"class":101},[24,6518,6519,6520],{},"Enable dependecy tracking\n",[71,6521,6523],{"className":73,"code":6522,"language":75,"meta":76,"style":76},"go mod init example\u002Fhello\n",[78,6524,6525],{"__ignoreMap":76},[81,6526,6527,6529,6532,6535],{"class":83,"line":84},[81,6528,6467],{"class":87},[81,6530,6531],{"class":101}," mod",[81,6533,6534],{"class":101}," init",[81,6536,6537],{"class":101}," example\u002Fhello\n",[24,6539,6540,6541,6544,6545,6583,6584],{},"Create a file ",[78,6542,6543],{},"hello.go"," in which to write our code.\n",[71,6546,6549],{"className":6547,"code":6548,"language":6467,"meta":76,"style":76},"language-go shiki shiki-themes github-light","package main\n\nimport \"fmt\"\n\nfunc main() {\n    fmt.Println(\"Hello, World!\")\n}\n",[78,6550,6551,6556,6560,6565,6569,6574,6579],{"__ignoreMap":76},[81,6552,6553],{"class":83,"line":84},[81,6554,6555],{},"package main\n",[81,6557,6558],{"class":83,"line":95},[81,6559,978],{"emptyLinePlaceholder":977},[81,6561,6562],{"class":83,"line":319},[81,6563,6564],{},"import \"fmt\"\n",[81,6566,6567],{"class":83,"line":328},[81,6568,978],{"emptyLinePlaceholder":977},[81,6570,6571],{"class":83,"line":891},[81,6572,6573],{},"func main() {\n",[81,6575,6576],{"class":83,"line":899},[81,6577,6578],{},"    fmt.Println(\"Hello, World!\")\n",[81,6580,6581],{"class":83,"line":910},[81,6582,2243],{},"\nIn this code, we:\n",[21,6585,6586,6593,6606],{},[24,6587,6588,6589,6592],{},"Declare a ",[78,6590,6591],{},"main"," package (a package is a way to group functions, and it's made up of all the files in the same directory).",[24,6594,6595,6596,6599,6600,6605],{},"Import the popular ",[78,6597,6598],{},"fmt"," package, which contains functions for formatting text, including printing to the console. This package is one of the ",[1566,6601,6604],{"href":6602,"rel":6603},"https:\u002F\u002Fpkg.go.dev\u002Fstd",[1570],"standard library packages"," we got when we installed Go.",[24,6607,6608,6609,6611,6612,6614,6615,6617],{},"Implement a ",[78,6610,6591],{}," function to print a message to the console. A ",[78,6613,6591],{}," function executes by default when we run the ",[78,6616,6591],{}," package.",[24,6619,6620,6621,5424,6635],{},"Run the code\n",[71,6622,6624],{"className":73,"code":6623,"language":75,"meta":76,"style":76},"go run hello.go\n",[78,6625,6626],{"__ignoreMap":76},[81,6627,6628,6630,6632],{"class":83,"line":84},[81,6629,6467],{"class":87},[81,6631,2047],{"class":101},[81,6633,6634],{"class":101}," hello.go\n",[71,6636,6638],{"className":73,"code":6637,"language":75,"meta":76,"style":76},"Hello, World!\n",[78,6639,6640],{"__ignoreMap":76},[81,6641,6642,6645],{"class":83,"line":84},[81,6643,6644],{"class":87},"Hello,",[81,6646,6647],{"class":101}," World!\n",[1874,6649,6650],{},[11,6651,6652,6653,6656,6657,6660],{},"The ",[78,6654,6655],{},"go run"," command is one of many go commands we'll use to get things done with Go. Use the ",[78,6658,6659],{},"go help"," command to get a list of the others:",[71,6662,6664],{"className":73,"code":6663,"language":75,"meta":76,"style":76},"govind@debian:~$ go help\nGo is a tool for managing Go source code.\n\nUsage:\n\n    go \u003Ccommand> [arguments]\n\nThe commands are:\n\n    bug         start a bug report\n    build       compile packages and dependencies\n    clean       remove object files and cached files\n    doc         show documentation for package or symbol\n    env         print Go environment information\n    fix         update packages to use new APIs\n    fmt         gofmt (reformat) package sources\n    generate    generate Go files by processing source\n    get         add dependencies to current module and install them\n    install     compile and install packages and dependencies\n    list        list packages or modules\n    mod         module maintenance\n    work        workspace maintenance\n    run         compile and run Go program\n    telemetry   manage telemetry data and settings\n    test        test packages\n    tool        run specified go tool\n    version     print Go version\n    vet         report likely mistakes in packages\n\nUse \"go help \u003Ccommand>\" for more information about a command.\n",[78,6665,6666,6677,6706,6710,6715,6719,6737,6741,6752,6756,6772,6789,6811,6833,6849,6871,6882,6902,6928,6946,6961,6972,6982,6999,7018,7029,7045,7057,7076,7080],{"__ignoreMap":76},[81,6667,6668,6671,6674],{"class":83,"line":84},[81,6669,6670],{"class":87},"govind@debian:~$",[81,6672,6673],{"class":101}," go",[81,6675,6676],{"class":101}," help\n",[81,6678,6679,6682,6685,6688,6691,6694,6697,6700,6703],{"class":83,"line":95},[81,6680,6681],{"class":87},"Go",[81,6683,6684],{"class":101}," is",[81,6686,6687],{"class":101}," a",[81,6689,6690],{"class":101}," tool",[81,6692,6693],{"class":101}," for",[81,6695,6696],{"class":101}," managing",[81,6698,6699],{"class":101}," Go",[81,6701,6702],{"class":101}," source",[81,6704,6705],{"class":101}," code.\n",[81,6707,6708],{"class":83,"line":319},[81,6709,978],{"emptyLinePlaceholder":977},[81,6711,6712],{"class":83,"line":328},[81,6713,6714],{"class":87},"Usage:\n",[81,6716,6717],{"class":83,"line":891},[81,6718,978],{"emptyLinePlaceholder":977},[81,6720,6721,6724,6726,6729,6732,6734],{"class":83,"line":899},[81,6722,6723],{"class":87},"    go",[81,6725,5494],{"class":4539},[81,6727,6728],{"class":101},"comman",[81,6730,6731],{"class":859},"d",[81,6733,5151],{"class":4539},[81,6735,6736],{"class":859}," [arguments]\n",[81,6738,6739],{"class":83,"line":910},[81,6740,978],{"emptyLinePlaceholder":977},[81,6742,6743,6746,6749],{"class":83,"line":921},[81,6744,6745],{"class":87},"The",[81,6747,6748],{"class":101}," commands",[81,6750,6751],{"class":101}," are:\n",[81,6753,6754],{"class":83,"line":931},[81,6755,978],{"emptyLinePlaceholder":977},[81,6757,6758,6761,6764,6766,6769],{"class":83,"line":942},[81,6759,6760],{"class":87},"    bug",[81,6762,6763],{"class":101},"         start",[81,6765,6687],{"class":101},[81,6767,6768],{"class":101}," bug",[81,6770,6771],{"class":101}," report\n",[81,6773,6774,6777,6780,6783,6786],{"class":83,"line":950},[81,6775,6776],{"class":87},"    build",[81,6778,6779],{"class":101},"       compile",[81,6781,6782],{"class":101}," packages",[81,6784,6785],{"class":101}," and",[81,6787,6788],{"class":101}," dependencies\n",[81,6790,6791,6794,6797,6800,6803,6805,6808],{"class":83,"line":959},[81,6792,6793],{"class":87},"    clean",[81,6795,6796],{"class":101},"       remove",[81,6798,6799],{"class":101}," object",[81,6801,6802],{"class":101}," files",[81,6804,6785],{"class":101},[81,6806,6807],{"class":101}," cached",[81,6809,6810],{"class":101}," files\n",[81,6812,6813,6816,6819,6822,6824,6827,6830],{"class":83,"line":967},[81,6814,6815],{"class":87},"    doc",[81,6817,6818],{"class":101},"         show",[81,6820,6821],{"class":101}," documentation",[81,6823,6693],{"class":101},[81,6825,6826],{"class":101}," package",[81,6828,6829],{"class":101}," or",[81,6831,6832],{"class":101}," symbol\n",[81,6834,6835,6838,6841,6843,6846],{"class":83,"line":974},[81,6836,6837],{"class":87},"    env",[81,6839,6840],{"class":101},"         print",[81,6842,6699],{"class":101},[81,6844,6845],{"class":101}," environment",[81,6847,6848],{"class":101}," information\n",[81,6850,6851,6854,6857,6859,6862,6865,6868],{"class":83,"line":981},[81,6852,6853],{"class":87},"    fix",[81,6855,6856],{"class":101},"         update",[81,6858,6782],{"class":101},[81,6860,6861],{"class":101}," to",[81,6863,6864],{"class":101}," use",[81,6866,6867],{"class":101}," new",[81,6869,6870],{"class":101}," APIs\n",[81,6872,6873,6876,6879],{"class":83,"line":989},[81,6874,6875],{"class":87},"    fmt",[81,6877,6878],{"class":101},"         gofmt",[81,6880,6881],{"class":859}," (reformat) package sources\n",[81,6883,6884,6887,6889,6891,6893,6896,6899],{"class":83,"line":999},[81,6885,6886],{"class":87},"    generate",[81,6888,6886],{"class":101},[81,6890,6699],{"class":101},[81,6892,6802],{"class":101},[81,6894,6895],{"class":101}," by",[81,6897,6898],{"class":101}," processing",[81,6900,6901],{"class":101}," source\n",[81,6903,6904,6907,6910,6913,6915,6918,6921,6923,6925],{"class":83,"line":1006},[81,6905,6906],{"class":87},"    get",[81,6908,6909],{"class":101},"         add",[81,6911,6912],{"class":101}," dependencies",[81,6914,6861],{"class":101},[81,6916,6917],{"class":101}," current",[81,6919,6920],{"class":101}," module",[81,6922,6785],{"class":101},[81,6924,4685],{"class":101},[81,6926,6927],{"class":101}," them\n",[81,6929,6930,6933,6936,6938,6940,6942,6944],{"class":83,"line":1017},[81,6931,6932],{"class":87},"    install",[81,6934,6935],{"class":101},"     compile",[81,6937,6785],{"class":101},[81,6939,4685],{"class":101},[81,6941,6782],{"class":101},[81,6943,6785],{"class":101},[81,6945,6788],{"class":101},[81,6947,6948,6951,6954,6956,6958],{"class":83,"line":1028},[81,6949,6950],{"class":87},"    list",[81,6952,6953],{"class":101},"        list",[81,6955,6782],{"class":101},[81,6957,6829],{"class":101},[81,6959,6960],{"class":101}," modules\n",[81,6962,6963,6966,6969],{"class":83,"line":1037},[81,6964,6965],{"class":87},"    mod",[81,6967,6968],{"class":101},"         module",[81,6970,6971],{"class":101}," maintenance\n",[81,6973,6974,6977,6980],{"class":83,"line":1047},[81,6975,6976],{"class":87},"    work",[81,6978,6979],{"class":101},"        workspace",[81,6981,6971],{"class":101},[81,6983,6984,6987,6990,6992,6994,6996],{"class":83,"line":1057},[81,6985,6986],{"class":87},"    run",[81,6988,6989],{"class":101},"         compile",[81,6991,6785],{"class":101},[81,6993,2047],{"class":101},[81,6995,6699],{"class":101},[81,6997,6998],{"class":101}," program\n",[81,7000,7001,7004,7007,7010,7013,7015],{"class":83,"line":1065},[81,7002,7003],{"class":87},"    telemetry",[81,7005,7006],{"class":101},"   manage",[81,7008,7009],{"class":101}," telemetry",[81,7011,7012],{"class":101}," data",[81,7014,6785],{"class":101},[81,7016,7017],{"class":101}," settings\n",[81,7019,7020,7023,7026],{"class":83,"line":1073},[81,7021,7022],{"class":91},"    test",[81,7024,7025],{"class":101},"        test",[81,7027,7028],{"class":101}," packages\n",[81,7030,7031,7034,7037,7040,7042],{"class":83,"line":1081},[81,7032,7033],{"class":87},"    tool",[81,7035,7036],{"class":101},"        run",[81,7038,7039],{"class":101}," specified",[81,7041,6673],{"class":101},[81,7043,7044],{"class":101}," tool\n",[81,7046,7047,7050,7053,7055],{"class":83,"line":1089},[81,7048,7049],{"class":87},"    version",[81,7051,7052],{"class":101},"     print",[81,7054,6699],{"class":101},[81,7056,4724],{"class":101},[81,7058,7059,7062,7065,7068,7071,7074],{"class":83,"line":1097},[81,7060,7061],{"class":87},"    vet",[81,7063,7064],{"class":101},"         report",[81,7066,7067],{"class":101}," likely",[81,7069,7070],{"class":101}," mistakes",[81,7072,7073],{"class":101}," in",[81,7075,7028],{"class":101},[81,7077,7078],{"class":83,"line":1104},[81,7079,978],{"emptyLinePlaceholder":977},[81,7081,7082,7085,7088,7090,7093,7096,7099,7101],{"class":83,"line":1111},[81,7083,7084],{"class":87},"Use",[81,7086,7087],{"class":101}," \"go help \u003Ccommand>\"",[81,7089,6693],{"class":101},[81,7091,7092],{"class":101}," more",[81,7094,7095],{"class":101}," information",[81,7097,7098],{"class":101}," about",[81,7100,6687],{"class":101},[81,7102,7103],{"class":101}," command.\n",[44,7105,7107],{"id":7106},"packages-and-imports","Packages and Imports",[11,7109,7110,7111,7114,7115,1187],{},"Go does not support Classes like in OOPs programming languages such as Java, it uses the package system instead. Each package is a directory in your workspace, and each go file must belong to some package. Hence, each file should start with the keyword ",[78,7112,7113],{},"package"," followed by the package name. A go executable must contain ",[78,7116,7117],{},"package main",[11,7119,7120,7121,7124],{},"A package can be imported by using the ",[78,7122,7123],{},"import"," keyword followed by the list of packages inside parenthesis.",[11,7126,7127],{},"The standard library comes preinstalled, with Go, and contains the most essential and useful packages. \"fmt\" is used to export Println which prints to console.",[1874,7129,7130],{},[11,7131,7132],{},"Go does not allow unused imports.",[71,7134,7136],{"className":6547,"code":7135,"language":6467,"meta":76,"style":76},"package main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"time\"\n)\n",[78,7137,7138,7142,7146,7151,7156,7161,7166],{"__ignoreMap":76},[81,7139,7140],{"class":83,"line":84},[81,7141,6555],{},[81,7143,7144],{"class":83,"line":95},[81,7145,978],{"emptyLinePlaceholder":977},[81,7147,7148],{"class":83,"line":319},[81,7149,7150],{},"import (\n",[81,7152,7153],{"class":83,"line":328},[81,7154,7155],{},"    \"fmt\"\n",[81,7157,7158],{"class":83,"line":891},[81,7159,7160],{},"    \"log\"\n",[81,7162,7163],{"class":83,"line":899},[81,7164,7165],{},"    \"time\"\n",[81,7167,7168],{"class":83,"line":910},[81,7169,7170],{},")\n",[44,7172,7174],{"id":7173},"using-an-external-package","Using an external package",[11,7176,7177],{},"When we need our code to do something that might have been implemented by someone else, we can look for a package that has functions we can use in our code.",[11,7179,7180],{},"Let's Make our printed message a little more interesting with a function from an external module.",[339,7182,7183,7191,7194,7197],{},[24,7184,2071,7185,7190],{},[1566,7186,7189],{"href":7187,"rel":7188},"https:\u002F\u002Fpkg.go.dev",[1570],"pkg.go.dev"," and search for a \"quote\" package.",[24,7192,7193],{},"Locate and click the rsc.io\u002Fquote package in search results (if we see rsc.io\u002Fquote\u002Fv4, ignore it for now).",[24,7195,7196],{},"In the Documentation section, under Index, note the list of functions we can call from our code. we'll use the Go function.",[24,7198,7199],{},"At the top of this page, note that package quote is included in the rsc.io\u002Fquote module.",[11,7201,7202,7203,7206],{},"we can use the pkg.go.dev site to find published modules whose packages have functions we can use in our own code. Packages are published in modules like ",[78,7204,7205],{},"rsc.io\u002Fquote"," where others can use them. Modules are improved with new versions over time, and we can upgrade our code to use the improved versions.",[339,7208,7209,7262,7286],{"start":891},[24,7210,6540,7211,7214,7215],{},[78,7212,7213],{},"quote.go"," and add the following code",[71,7216,7218],{"className":6547,"code":7217,"language":6467,"meta":76,"style":76},"package main\n\nimport (\n    \"fmt\"\n    \"rsc.io\u002Fquote\"\n)\n\nfunc main() {\n    fmt.Println(quote.Go())\n}\n",[78,7219,7220,7224,7228,7232,7236,7241,7245,7249,7253,7258],{"__ignoreMap":76},[81,7221,7222],{"class":83,"line":84},[81,7223,6555],{},[81,7225,7226],{"class":83,"line":95},[81,7227,978],{"emptyLinePlaceholder":977},[81,7229,7230],{"class":83,"line":319},[81,7231,7150],{},[81,7233,7234],{"class":83,"line":328},[81,7235,7155],{},[81,7237,7238],{"class":83,"line":891},[81,7239,7240],{},"    \"rsc.io\u002Fquote\"\n",[81,7242,7243],{"class":83,"line":899},[81,7244,7170],{},[81,7246,7247],{"class":83,"line":910},[81,7248,978],{"emptyLinePlaceholder":977},[81,7250,7251],{"class":83,"line":921},[81,7252,6573],{},[81,7254,7255],{"class":83,"line":931},[81,7256,7257],{},"    fmt.Println(quote.Go())\n",[81,7259,7260],{"class":83,"line":942},[81,7261,2243],{},[24,7263,7264,7265,7267,7268,7271,7272],{},"Add new module requirements and sums.",[5967,7266],{},"Go will add the quote module as a requirement, as well as a ",[78,7269,7270],{},"go.sum"," file for use in authenticating the module.",[71,7273,7275],{"className":73,"code":7274,"language":75,"meta":76,"style":76},"go mod tidy\n",[78,7276,7277],{"__ignoreMap":76},[81,7278,7279,7281,7283],{"class":83,"line":84},[81,7280,6467],{"class":87},[81,7282,6531],{"class":101},[81,7284,7285],{"class":101}," tidy\n",[24,7287,7288,7289,7303,5093,7305,7318,7320],{},"Run the code to see the message generated by the function we're calling.",[71,7290,7292],{"className":73,"code":7291,"language":75,"meta":76,"style":76},"go run quote.go\n",[78,7293,7294],{"__ignoreMap":76},[81,7295,7296,7298,7300],{"class":83,"line":84},[81,7297,6467],{"class":87},[81,7299,2047],{"class":101},[81,7301,7302],{"class":101}," quote.go\n",[5967,7304],{},[71,7306,7308],{"className":73,"code":7307,"language":75,"meta":76,"style":76},"Don't communicate by sharing memory, share memory by communicating.\n",[78,7309,7310],{"__ignoreMap":76},[81,7311,7312,7315],{"class":83,"line":84},[81,7313,7314],{"class":87},"Don",[81,7316,7317],{"class":87},"'t communicate by sharing memory, share memory by communicating.\n",[5967,7319],{},"Notice that our code calls the Go function, printing a clever message about communication.",[1874,7322,7323],{},[11,7324,7325,7326,7329,7330,7332],{},"When we ran ",[78,7327,7328],{},"go mod tidy",", it located and downloaded the ",[78,7331,7205],{}," module that contains the package you imported. By default, it downloaded the latest version.",[44,7334,7336],{"id":7335},"language-concepts","Language concepts",[63,7338,7340],{"id":7339},"_1-variables","1. Variables",[11,7342,7343,7344,7347],{},"Go’s basic primitive types are bool, string, int, uint, float, and complex, the size of the type can be specified next to the type, uint32. A variable is declared by the ",[78,7345,7346],{},"var"," keyword followed by the variable name and the type.",[11,7349,7350,7351,7354],{},"variables can also be initialized with a shorthand notation ",[78,7352,7353],{},":="," as Go can infer the type.",[1874,7356,7357],{},[11,7358,7359],{},"Just like imports, unused variables are not allowed.",[71,7361,7363],{"className":6547,"code":7362,"language":6467,"meta":76,"style":76},"package main\n\nvar x int = 5\nvar y int = 6\n\nsum := x + y\n",[78,7364,7365,7369,7373,7378,7383,7387],{"__ignoreMap":76},[81,7366,7367],{"class":83,"line":84},[81,7368,6555],{},[81,7370,7371],{"class":83,"line":95},[81,7372,978],{"emptyLinePlaceholder":977},[81,7374,7375],{"class":83,"line":319},[81,7376,7377],{},"var x int = 5\n",[81,7379,7380],{"class":83,"line":328},[81,7381,7382],{},"var y int = 6\n",[81,7384,7385],{"class":83,"line":891},[81,7386,978],{"emptyLinePlaceholder":977},[81,7388,7389],{"class":83,"line":899},[81,7390,7391],{},"sum := x + y\n",[11,7393,7394],{},"Also, Go does not use semicolons to end a statement.",[11,7396,7397],{},"An important point to note is how Go scopes variables with a package, a variable is public if the first letter is in Captial, else private, same goes for functions.",[71,7399,7401],{"className":6547,"code":7400,"language":6467,"meta":76,"style":76},"package main\n\nX := 5 \u002F\u002F public\ny := 6 \u002F\u002F private\n\nfunc Add() { \u002F\u002F public\n\n}\n\nfunc add() { \u002F\u002F private\n\n}\n",[78,7402,7403,7407,7411,7416,7421,7425,7430,7434,7438,7442,7447,7451],{"__ignoreMap":76},[81,7404,7405],{"class":83,"line":84},[81,7406,6555],{},[81,7408,7409],{"class":83,"line":95},[81,7410,978],{"emptyLinePlaceholder":977},[81,7412,7413],{"class":83,"line":319},[81,7414,7415],{},"X := 5 \u002F\u002F public\n",[81,7417,7418],{"class":83,"line":328},[81,7419,7420],{},"y := 6 \u002F\u002F private\n",[81,7422,7423],{"class":83,"line":891},[81,7424,978],{"emptyLinePlaceholder":977},[81,7426,7427],{"class":83,"line":899},[81,7428,7429],{},"func Add() { \u002F\u002F public\n",[81,7431,7432],{"class":83,"line":910},[81,7433,978],{"emptyLinePlaceholder":977},[81,7435,7436],{"class":83,"line":921},[81,7437,2243],{},[81,7439,7440],{"class":83,"line":931},[81,7441,978],{"emptyLinePlaceholder":977},[81,7443,7444],{"class":83,"line":942},[81,7445,7446],{},"func add() { \u002F\u002F private\n",[81,7448,7449],{"class":83,"line":950},[81,7450,978],{"emptyLinePlaceholder":977},[81,7452,7453],{"class":83,"line":959},[81,7454,2243],{},[63,7456,7458],{"id":7457},"_2-functions","2. Functions",[11,7460,7461,7462,7465,7466,7468],{},"Functions are an essential part of Go, and of course, the above won’t work as execution has to happen in a function body. Functions are declared with the keyword ",[78,7463,7464],{},"func"," followed by the function name, arguments, and return type. A Go application must contain the ",[78,7467,6591],{}," function which is the entry point to the application. It does not take any arguments or return anything. The opening braces of the function must start at the same level as the function and cannot move to the new line.",[11,7470,7471],{},"function parameters are declared with their name followed by the type and separated by a comma. The return type must be provided if the function returns, as a shortcut the return variable can also be declared to avoid declaring another variable inside the function, here’s an example.",[71,7473,7475],{"className":6547,"code":7474,"language":6467,"meta":76,"style":76},"package main\n\nfunc sum(x int, y int) int {\n    sum := x + y\n    return sum\n}\n\n\u002F\u002F OR\n\nfunc sum(x int, y int) (sum int) {\n    sum := x + y\n    return\n}\n",[78,7476,7477,7481,7485,7490,7495,7500,7504,7508,7513,7517,7522,7526,7531],{"__ignoreMap":76},[81,7478,7479],{"class":83,"line":84},[81,7480,6555],{},[81,7482,7483],{"class":83,"line":95},[81,7484,978],{"emptyLinePlaceholder":977},[81,7486,7487],{"class":83,"line":319},[81,7488,7489],{},"func sum(x int, y int) int {\n",[81,7491,7492],{"class":83,"line":328},[81,7493,7494],{},"    sum := x + y\n",[81,7496,7497],{"class":83,"line":891},[81,7498,7499],{},"    return sum\n",[81,7501,7502],{"class":83,"line":899},[81,7503,2243],{},[81,7505,7506],{"class":83,"line":910},[81,7507,978],{"emptyLinePlaceholder":977},[81,7509,7510],{"class":83,"line":921},[81,7511,7512],{},"\u002F\u002F OR\n",[81,7514,7515],{"class":83,"line":931},[81,7516,978],{"emptyLinePlaceholder":977},[81,7518,7519],{"class":83,"line":942},[81,7520,7521],{},"func sum(x int, y int) (sum int) {\n",[81,7523,7524],{"class":83,"line":950},[81,7525,7494],{},[81,7527,7528],{"class":83,"line":959},[81,7529,7530],{},"    return\n",[81,7532,7533],{"class":83,"line":967},[81,7534,2243],{},[63,7536,7538],{"id":7537},"_3-arrays-slices-and-maps","3. Arrays, Slices, and Maps",[11,7540,7541],{},"Arrays can be declared by simply specifying the datatype next to brackets with an integer denoting the size of the array. Then, arrays can be assigned by their index, a more convenient way to initialize is to use the shorthand syntax along with the data in parenthesis.",[71,7543,7545],{"className":6547,"code":7544,"language":6467,"meta":76,"style":76},"package main\n\nvar arr [4]int\narr[0] = 1\narr[1] = 2\n\n\u002F\u002F OR\n\narr := [4]int{1,2,3,4}\n",[78,7546,7547,7551,7555,7560,7565,7570,7574,7578,7582],{"__ignoreMap":76},[81,7548,7549],{"class":83,"line":84},[81,7550,6555],{},[81,7552,7553],{"class":83,"line":95},[81,7554,978],{"emptyLinePlaceholder":977},[81,7556,7557],{"class":83,"line":319},[81,7558,7559],{},"var arr [4]int\n",[81,7561,7562],{"class":83,"line":328},[81,7563,7564],{},"arr[0] = 1\n",[81,7566,7567],{"class":83,"line":891},[81,7568,7569],{},"arr[1] = 2\n",[81,7571,7572],{"class":83,"line":899},[81,7573,978],{"emptyLinePlaceholder":977},[81,7575,7576],{"class":83,"line":910},[81,7577,7512],{},[81,7579,7580],{"class":83,"line":921},[81,7581,978],{"emptyLinePlaceholder":977},[81,7583,7584],{"class":83,"line":931},[81,7585,7586],{},"arr := [4]int{1,2,3,4}\n",[11,7588,7589,7590,7593],{},"But there’s a problem here. You cannot modify the length of the array, wouldn't it be more convenient when you don’t know the size yet? That’s where ",[78,7591,7592],{},"Slices"," come in, slices are simply dynamic arrays. you can declare a slice just like arrays, without specifying the size.",[11,7595,7596],{},"Slices can be really useful in performing a lot of operations. The copy or append function can be used to manipulate the slice. Slices can also be concatenated using the append with the spread operator(…). A slice can be sliced using its indices within the brackets. Below are some examples.",[71,7598,7600],{"className":6547,"code":7599,"language":6467,"meta":76,"style":76},"package main\n\nimport \"fmt\"\n\nfunc main() {\n    slice := []int{1,2,3,4,5}\n\n    slice1 := slice[2:]\n    slice2 := slice[:2]\n\n    slice = append(slice ,4)\n\n    slicecat := append(slice, slice...)\n\n    fmt.Println(slice, slice1, slice2, slicecat)\n}\n",[78,7601,7602,7606,7610,7614,7618,7622,7627,7631,7636,7641,7645,7650,7654,7659,7663,7668],{"__ignoreMap":76},[81,7603,7604],{"class":83,"line":84},[81,7605,6555],{},[81,7607,7608],{"class":83,"line":95},[81,7609,978],{"emptyLinePlaceholder":977},[81,7611,7612],{"class":83,"line":319},[81,7613,6564],{},[81,7615,7616],{"class":83,"line":328},[81,7617,978],{"emptyLinePlaceholder":977},[81,7619,7620],{"class":83,"line":891},[81,7621,6573],{},[81,7623,7624],{"class":83,"line":899},[81,7625,7626],{},"    slice := []int{1,2,3,4,5}\n",[81,7628,7629],{"class":83,"line":910},[81,7630,978],{"emptyLinePlaceholder":977},[81,7632,7633],{"class":83,"line":921},[81,7634,7635],{},"    slice1 := slice[2:]\n",[81,7637,7638],{"class":83,"line":931},[81,7639,7640],{},"    slice2 := slice[:2]\n",[81,7642,7643],{"class":83,"line":942},[81,7644,978],{"emptyLinePlaceholder":977},[81,7646,7647],{"class":83,"line":950},[81,7648,7649],{},"    slice = append(slice ,4)\n",[81,7651,7652],{"class":83,"line":959},[81,7653,978],{"emptyLinePlaceholder":977},[81,7655,7656],{"class":83,"line":967},[81,7657,7658],{},"    slicecat := append(slice, slice...)\n",[81,7660,7661],{"class":83,"line":974},[81,7662,978],{"emptyLinePlaceholder":977},[81,7664,7665],{"class":83,"line":981},[81,7666,7667],{},"    fmt.Println(slice, slice1, slice2, slicecat)\n",[81,7669,7670],{"class":83,"line":989},[81,7671,2243],{},[11,7673,7674],{},"The append function does not modify the slice but returns a new slice from the given one. Here’s the output.",[71,7676,7678],{"className":73,"code":7677,"language":75,"meta":76,"style":76},"# output\n[1 2 3 4 5 4] [3 4 5] [1 2] [1 2 3 4 5 4 1 2 3 4 5 4]\n",[78,7679,7680,7685],{"__ignoreMap":76},[81,7681,7682],{"class":83,"line":84},[81,7683,7684],{"class":4780},"# output\n",[81,7686,7687,7690,7693,7696,7699,7702,7705,7708,7711,7713,7716,7718,7721,7723,7725,7727,7729,7731,7733,7736,7738,7740,7742,7744],{"class":83,"line":95},[81,7688,7689],{"class":859},"[",[81,7691,7692],{"class":91},"1",[81,7694,7695],{"class":91}," 2",[81,7697,7698],{"class":91}," 3",[81,7700,7701],{"class":91}," 4",[81,7703,7704],{"class":91}," 5",[81,7706,7707],{"class":859}," 4] [",[81,7709,7710],{"class":91},"3",[81,7712,7701],{"class":91},[81,7714,7715],{"class":859}," 5] [",[81,7717,7692],{"class":91},[81,7719,7720],{"class":859}," 2] [",[81,7722,7692],{"class":91},[81,7724,7695],{"class":91},[81,7726,7698],{"class":91},[81,7728,7701],{"class":91},[81,7730,7704],{"class":91},[81,7732,7701],{"class":91},[81,7734,7735],{"class":91}," 1",[81,7737,7695],{"class":91},[81,7739,7698],{"class":91},[81,7741,7701],{"class":91},[81,7743,7704],{"class":91},[81,7745,7746],{"class":859}," 4]\n",[11,7748,7749],{},"Maps are equivalent to a HasMap in Java or a Dictionary in python. They store key-value pairs. A map can be created using the make keyword followed by the keyword map and the datatype of the key in brackets and value next to it.",[11,7751,7752,7753,7756],{},"Maps are simple to operate on, they can be assigned values by using the ",[78,7754,7755],{},"[ ]"," operator specifying the key and value, and a key can be removed by using the delete function.",[71,7758,7760],{"className":6547,"code":7759,"language":6467,"meta":76,"style":76},"package main\n\nimport \"fmt\"\n\nfunc main() {\n    elements := make(map[string]int)\n\n    elements[\"first\"] = 1\n    elements[\"second\"] = 2\n\n    fmt.Println(elements)\n\n    delete(elements, \"first\")\n\n    fmt.Println(elements)\n}\n",[78,7761,7762,7766,7770,7774,7778,7782,7787,7791,7796,7801,7805,7810,7814,7819,7823,7827],{"__ignoreMap":76},[81,7763,7764],{"class":83,"line":84},[81,7765,6555],{},[81,7767,7768],{"class":83,"line":95},[81,7769,978],{"emptyLinePlaceholder":977},[81,7771,7772],{"class":83,"line":319},[81,7773,6564],{},[81,7775,7776],{"class":83,"line":328},[81,7777,978],{"emptyLinePlaceholder":977},[81,7779,7780],{"class":83,"line":891},[81,7781,6573],{},[81,7783,7784],{"class":83,"line":899},[81,7785,7786],{},"    elements := make(map[string]int)\n",[81,7788,7789],{"class":83,"line":910},[81,7790,978],{"emptyLinePlaceholder":977},[81,7792,7793],{"class":83,"line":921},[81,7794,7795],{},"    elements[\"first\"] = 1\n",[81,7797,7798],{"class":83,"line":931},[81,7799,7800],{},"    elements[\"second\"] = 2\n",[81,7802,7803],{"class":83,"line":942},[81,7804,978],{"emptyLinePlaceholder":977},[81,7806,7807],{"class":83,"line":950},[81,7808,7809],{},"    fmt.Println(elements)\n",[81,7811,7812],{"class":83,"line":959},[81,7813,978],{"emptyLinePlaceholder":977},[81,7815,7816],{"class":83,"line":967},[81,7817,7818],{},"    delete(elements, \"first\")\n",[81,7820,7821],{"class":83,"line":974},[81,7822,978],{"emptyLinePlaceholder":977},[81,7824,7825],{"class":83,"line":981},[81,7826,7809],{},[81,7828,7829],{"class":83,"line":989},[81,7830,2243],{},[11,7832,5093],{},[71,7834,7836],{"className":73,"code":7835,"language":75,"meta":76,"style":76},"map[first:1 second:2]\nmap[second:2]\n",[78,7837,7838,7846],{"__ignoreMap":76},[81,7839,7840,7843],{"class":83,"line":84},[81,7841,7842],{"class":87},"map[first:1",[81,7844,7845],{"class":101}," second:2]\n",[81,7847,7848],{"class":83,"line":95},[81,7849,7850],{"class":87},"map[second:2]\n",[63,7852,7854],{"id":7853},"_3-loops","3. Loops",[11,7856,7857,7858,7861,7862,7864],{},"Loops in Go exist in the simplest form, there is only one looping syntax, the ",[78,7859,7860],{},"for"," loop. The ",[78,7863,7860],{}," loop can be written in multiple ways to meet your looping needs. The first syntax is a familiar one starting with the pointer variable i and followed by condition and incrementation. The below example will print 1 to 5.",[71,7866,7868],{"className":6547,"code":7867,"language":6467,"meta":76,"style":76},"package main\n\nimport \"fmt\"\n\nfunc main() {\n    arr := []int{1,2,3,4,5}\n\n    for i := 0; i \u003C len(arr); i++ {\n        fmt.Println(arr[i])\n    }\n}\n",[78,7869,7870,7874,7878,7882,7886,7890,7895,7899,7904,7909,7913],{"__ignoreMap":76},[81,7871,7872],{"class":83,"line":84},[81,7873,6555],{},[81,7875,7876],{"class":83,"line":95},[81,7877,978],{"emptyLinePlaceholder":977},[81,7879,7880],{"class":83,"line":319},[81,7881,6564],{},[81,7883,7884],{"class":83,"line":328},[81,7885,978],{"emptyLinePlaceholder":977},[81,7887,7888],{"class":83,"line":891},[81,7889,6573],{},[81,7891,7892],{"class":83,"line":899},[81,7893,7894],{},"    arr := []int{1,2,3,4,5}\n",[81,7896,7897],{"class":83,"line":910},[81,7898,978],{"emptyLinePlaceholder":977},[81,7900,7901],{"class":83,"line":921},[81,7902,7903],{},"    for i := 0; i \u003C len(arr); i++ {\n",[81,7905,7906],{"class":83,"line":931},[81,7907,7908],{},"        fmt.Println(arr[i])\n",[81,7910,7911],{"class":83,"line":942},[81,7912,2276],{},[81,7914,7915],{"class":83,"line":950},[81,7916,2243],{},[11,7918,7919],{},"Oh! you badly miss the while loop? Don’t worry, Go has you covered, all you have to do is mention the condition with the for loop and use a pointer declared outside the loop just how you would when using a while loop.",[71,7921,7923],{"className":6547,"code":7922,"language":6467,"meta":76,"style":76},"package main\n\nimport \"fmt\"\n\nfunc main() {\n    arr := []int{1,2,3,4,5}\n\n    i := 0\n    for i \u003C len(arr) {\n        fmt.Println(arr[i])\n        i++\n    }\n}\n",[78,7924,7925,7929,7933,7937,7941,7945,7949,7953,7958,7963,7967,7972,7976],{"__ignoreMap":76},[81,7926,7927],{"class":83,"line":84},[81,7928,6555],{},[81,7930,7931],{"class":83,"line":95},[81,7932,978],{"emptyLinePlaceholder":977},[81,7934,7935],{"class":83,"line":319},[81,7936,6564],{},[81,7938,7939],{"class":83,"line":328},[81,7940,978],{"emptyLinePlaceholder":977},[81,7942,7943],{"class":83,"line":891},[81,7944,6573],{},[81,7946,7947],{"class":83,"line":899},[81,7948,7894],{},[81,7950,7951],{"class":83,"line":910},[81,7952,978],{"emptyLinePlaceholder":977},[81,7954,7955],{"class":83,"line":921},[81,7956,7957],{},"    i := 0\n",[81,7959,7960],{"class":83,"line":931},[81,7961,7962],{},"    for i \u003C len(arr) {\n",[81,7964,7965],{"class":83,"line":942},[81,7966,7908],{},[81,7968,7969],{"class":83,"line":950},[81,7970,7971],{},"        i++\n",[81,7973,7974],{"class":83,"line":959},[81,7975,2276],{},[81,7977,7978],{"class":83,"line":967},[81,7979,2243],{},[11,7981,7982],{},"The range function provides an easy way to access the index as well as value.",[71,7984,7986],{"className":6547,"code":7985,"language":6467,"meta":76,"style":76},"package main\n\nimport \"fmt\"\n\nfunc main() {\n    arr := []int{1,2,3,4,5}\n\n    for i,v := range(arr) {\n        fmt.Println(i, v)\n    }\n}\n",[78,7987,7988,7992,7996,8000,8004,8008,8012,8016,8021,8026,8030],{"__ignoreMap":76},[81,7989,7990],{"class":83,"line":84},[81,7991,6555],{},[81,7993,7994],{"class":83,"line":95},[81,7995,978],{"emptyLinePlaceholder":977},[81,7997,7998],{"class":83,"line":319},[81,7999,6564],{},[81,8001,8002],{"class":83,"line":328},[81,8003,978],{"emptyLinePlaceholder":977},[81,8005,8006],{"class":83,"line":891},[81,8007,6573],{},[81,8009,8010],{"class":83,"line":899},[81,8011,7894],{},[81,8013,8014],{"class":83,"line":910},[81,8015,978],{"emptyLinePlaceholder":977},[81,8017,8018],{"class":83,"line":921},[81,8019,8020],{},"    for i,v := range(arr) {\n",[81,8022,8023],{"class":83,"line":931},[81,8024,8025],{},"        fmt.Println(i, v)\n",[81,8027,8028],{"class":83,"line":942},[81,8029,2276],{},[81,8031,8032],{"class":83,"line":950},[81,8033,2243],{},[63,8035,8037],{"id":8036},"_4-struct","4. Struct",[11,8039,6652,8040,8043,8044,8047,8048,8050],{},[78,8041,8042],{},"struct"," keyword is to define a shape to your data. Since Go does not support classes, data of a certain shape requirement can be stored in variables of that type of struct. A struct is created using the keyword ",[78,8045,8046],{},"type"," and its properties can be accessed by the ",[78,8049,1187],{}," operator.",[71,8052,8054],{"className":6547,"code":8053,"language":6467,"meta":76,"style":76},"package main\n\nimport \"fmt\"\n\nfunc main() {\n    type Animal struct {\n        Name        string\n        animalType  string\n    }\n\n    giraffe := Animal(\"Giraffe\", \"Mammal\")\n\n    fmt.Println(giraffe.Name, giraffe.animalType)\n}\n",[78,8055,8056,8060,8064,8068,8072,8076,8081,8086,8091,8095,8099,8104,8108,8113],{"__ignoreMap":76},[81,8057,8058],{"class":83,"line":84},[81,8059,6555],{},[81,8061,8062],{"class":83,"line":95},[81,8063,978],{"emptyLinePlaceholder":977},[81,8065,8066],{"class":83,"line":319},[81,8067,6564],{},[81,8069,8070],{"class":83,"line":328},[81,8071,978],{"emptyLinePlaceholder":977},[81,8073,8074],{"class":83,"line":891},[81,8075,6573],{},[81,8077,8078],{"class":83,"line":899},[81,8079,8080],{},"    type Animal struct {\n",[81,8082,8083],{"class":83,"line":910},[81,8084,8085],{},"        Name        string\n",[81,8087,8088],{"class":83,"line":921},[81,8089,8090],{},"        animalType  string\n",[81,8092,8093],{"class":83,"line":931},[81,8094,2276],{},[81,8096,8097],{"class":83,"line":942},[81,8098,978],{"emptyLinePlaceholder":977},[81,8100,8101],{"class":83,"line":950},[81,8102,8103],{},"    giraffe := Animal(\"Giraffe\", \"Mammal\")\n",[81,8105,8106],{"class":83,"line":959},[81,8107,978],{"emptyLinePlaceholder":977},[81,8109,8110],{"class":83,"line":967},[81,8111,8112],{},"    fmt.Println(giraffe.Name, giraffe.animalType)\n",[81,8114,8115],{"class":83,"line":974},[81,8116,2243],{},[63,8118,8120],{"id":8119},"_5-nil-error-and-multiple-return-values","5. nil, error, and multiple return values",[11,8122,8123],{},"Go provides some smooth ways to handle the error and nil values. Both error and nil are native built-in types that can be used to perform validation before performing some operation. Go also supports returning multiple types from a function, this can be done using specifying the type within parenthesis in place of the return type.",[71,8125,8127],{"className":6547,"code":8126,"language":6467,"meta":76,"style":76},"package main\n\nimport \"fmt\"\n\nfunc main() {\n    a,b := sum(5,10)\n}\n\nfunc sum(x int, y int) (sum int, diff int) {\n    sum = x + y\n    diff = x - y\n    return\n}\n",[78,8128,8129,8133,8137,8141,8145,8149,8154,8158,8162,8167,8172,8177,8181],{"__ignoreMap":76},[81,8130,8131],{"class":83,"line":84},[81,8132,6555],{},[81,8134,8135],{"class":83,"line":95},[81,8136,978],{"emptyLinePlaceholder":977},[81,8138,8139],{"class":83,"line":319},[81,8140,6564],{},[81,8142,8143],{"class":83,"line":328},[81,8144,978],{"emptyLinePlaceholder":977},[81,8146,8147],{"class":83,"line":891},[81,8148,6573],{},[81,8150,8151],{"class":83,"line":899},[81,8152,8153],{},"    a,b := sum(5,10)\n",[81,8155,8156],{"class":83,"line":910},[81,8157,2243],{},[81,8159,8160],{"class":83,"line":921},[81,8161,978],{"emptyLinePlaceholder":977},[81,8163,8164],{"class":83,"line":931},[81,8165,8166],{},"func sum(x int, y int) (sum int, diff int) {\n",[81,8168,8169],{"class":83,"line":942},[81,8170,8171],{},"    sum = x + y\n",[81,8173,8174],{"class":83,"line":950},[81,8175,8176],{},"    diff = x - y\n",[81,8178,8179],{"class":83,"line":959},[81,8180,7530],{},[81,8182,8183],{"class":83,"line":967},[81,8184,2243],{},[11,8186,8187],{},"errors or nil can be returned depending on the operation performed using an if check. Here’s an example showing how you can handle errors by checking the input for a square root function.",[71,8189,8191],{"className":6547,"code":8190,"language":6467,"meta":76,"style":76},"package main\n\nimport (\n    \"fmt\"\n    \"math\"\n    \"errors\"\n)\n\nfunc main() {\n    result, err := sqrt(25)\n\n    if err != nil {\n        fmt.Println(err)\n    } else {\n        fmt.Println(result)\n    }\n}\n\nfunc sqrt(x float64) (float64, error) {\n    if x \u003C 0 {\n        return 0 , errors.New(\"x must be non negative number\")\n    }\n\n    retun math.Sqrt(x), nil\n}\n",[78,8192,8193,8197,8201,8205,8209,8214,8219,8223,8227,8231,8236,8240,8245,8250,8255,8260,8264,8268,8272,8277,8282,8287,8291,8295,8300],{"__ignoreMap":76},[81,8194,8195],{"class":83,"line":84},[81,8196,6555],{},[81,8198,8199],{"class":83,"line":95},[81,8200,978],{"emptyLinePlaceholder":977},[81,8202,8203],{"class":83,"line":319},[81,8204,7150],{},[81,8206,8207],{"class":83,"line":328},[81,8208,7155],{},[81,8210,8211],{"class":83,"line":891},[81,8212,8213],{},"    \"math\"\n",[81,8215,8216],{"class":83,"line":899},[81,8217,8218],{},"    \"errors\"\n",[81,8220,8221],{"class":83,"line":910},[81,8222,7170],{},[81,8224,8225],{"class":83,"line":921},[81,8226,978],{"emptyLinePlaceholder":977},[81,8228,8229],{"class":83,"line":931},[81,8230,6573],{},[81,8232,8233],{"class":83,"line":942},[81,8234,8235],{},"    result, err := sqrt(25)\n",[81,8237,8238],{"class":83,"line":950},[81,8239,978],{"emptyLinePlaceholder":977},[81,8241,8242],{"class":83,"line":959},[81,8243,8244],{},"    if err != nil {\n",[81,8246,8247],{"class":83,"line":967},[81,8248,8249],{},"        fmt.Println(err)\n",[81,8251,8252],{"class":83,"line":974},[81,8253,8254],{},"    } else {\n",[81,8256,8257],{"class":83,"line":981},[81,8258,8259],{},"        fmt.Println(result)\n",[81,8261,8262],{"class":83,"line":989},[81,8263,2276],{},[81,8265,8266],{"class":83,"line":999},[81,8267,2243],{},[81,8269,8270],{"class":83,"line":1006},[81,8271,978],{"emptyLinePlaceholder":977},[81,8273,8274],{"class":83,"line":1017},[81,8275,8276],{},"func sqrt(x float64) (float64, error) {\n",[81,8278,8279],{"class":83,"line":1028},[81,8280,8281],{},"    if x \u003C 0 {\n",[81,8283,8284],{"class":83,"line":1037},[81,8285,8286],{},"        return 0 , errors.New(\"x must be non negative number\")\n",[81,8288,8289],{"class":83,"line":1047},[81,8290,2276],{},[81,8292,8293],{"class":83,"line":1057},[81,8294,978],{"emptyLinePlaceholder":977},[81,8296,8297],{"class":83,"line":1065},[81,8298,8299],{},"    retun math.Sqrt(x), nil\n",[81,8301,8302],{"class":83,"line":1073},[81,8303,2243],{},[63,8305,8307],{"id":8306},"_6-pointers","6. Pointers",[11,8309,8310,8311,8314,8315,8318,8319,8321],{},"Pointers in Go are similar to pointers in other languages, you can refer to the memory address of the variable by prefixing the variable with an ",[78,8312,8313],{},"ampersand(&)"," symbol and dereference it using an ",[78,8316,8317],{},"asterisk(*)",", by default, go passes arguments by value not reference, you can accomplish this by prefixing that type of the argument in the function with an ",[78,8320,8317],{},", here’s an example.",[71,8323,8325],{"className":6547,"code":8324,"language":6467,"meta":76,"style":76},"package main\n\nimport \"fmt\"\n\nfunc main() {\n    i := 5\n    increment(&i)\n    fmt.Println(i)\n}\n\nfunc increment(i *int) {\n    *i++\n}\n",[78,8326,8327,8331,8335,8339,8343,8347,8352,8357,8362,8366,8370,8375,8380],{"__ignoreMap":76},[81,8328,8329],{"class":83,"line":84},[81,8330,6555],{},[81,8332,8333],{"class":83,"line":95},[81,8334,978],{"emptyLinePlaceholder":977},[81,8336,8337],{"class":83,"line":319},[81,8338,6564],{},[81,8340,8341],{"class":83,"line":328},[81,8342,978],{"emptyLinePlaceholder":977},[81,8344,8345],{"class":83,"line":891},[81,8346,6573],{},[81,8348,8349],{"class":83,"line":899},[81,8350,8351],{},"    i := 5\n",[81,8353,8354],{"class":83,"line":910},[81,8355,8356],{},"    increment(&i)\n",[81,8358,8359],{"class":83,"line":921},[81,8360,8361],{},"    fmt.Println(i)\n",[81,8363,8364],{"class":83,"line":931},[81,8365,2243],{},[81,8367,8368],{"class":83,"line":942},[81,8369,978],{"emptyLinePlaceholder":977},[81,8371,8372],{"class":83,"line":950},[81,8373,8374],{},"func increment(i *int) {\n",[81,8376,8377],{"class":83,"line":959},[81,8378,8379],{},"    *i++\n",[81,8381,8382],{"class":83,"line":967},[81,8383,2243],{},[11,8385,8386,8387,8390,8391,8394],{},"without the ",[78,8388,8389],{},"&"," it’d print 5 as a copy of the variable would have been passed, and once we have the reference, we need to deference the memory to get the value by using ",[78,8392,8393],{},"*"," on the variable again.",[11,8396,8397,8398,8401],{},"That’s it! you should be now ready to write your first program in Go, try practicing the code snippets and if you feel like challenging yourself more, try writing a basic HTTP server using the ",[78,8399,8400],{},"net"," package. This should give you enough practice to write some awesome packages or contribute to your favorite Go repository.",[11,8403,8404],{},"We'll explore concurrency and other powerful features of Go in another blog—so stay tuned.",[11,8406,8407],{},"Thanks for sticking around and coding along!",[11,8409,8410],{},"Here are some additional resources if you wish to dive deeper.",[21,8412,8413,8420,8427,8434],{},[24,8414,8415],{},[1566,8416,8419],{"href":8417,"rel":8418},"https:\u002F\u002Fgo.dev\u002F",[1570],"go.dev",[24,8421,8422],{},[1566,8423,8426],{"href":8424,"rel":8425},"https:\u002F\u002Fyoutu.be\u002FXCZWyN9ZbEQ?si=wT5Hf6TNadDtQiZk",[1570],"Golang Tutorial By Nana",[24,8428,8429],{},[1566,8430,8433],{"href":8431,"rel":8432},"https:\u002F\u002Fyoutube.com\u002Fplaylist?list=PL0xRBLFXXsP7-0IVCmoo2FEWBrQzfH2l8&si=7LoFNs4RBqA46C92",[1570],"How To Golang Playlist by Anthony GG",[24,8435,8436],{},[1566,8437,8440],{"href":8438,"rel":8439},"https:\u002F\u002Fmedium.com\u002Fa-journey-with-go",[1570],"A Journey With Go",[11,8442,8443],{},"Until next time happy coding, and go Go!",[1631,8445,8446],{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}",{"title":76,"searchDepth":95,"depth":95,"links":8448},[8449,8450,8451,8452,8453],{"id":6361,"depth":95,"text":6362},{"id":6491,"depth":95,"text":6492},{"id":7106,"depth":95,"text":7107},{"id":7173,"depth":95,"text":7174},{"id":7335,"depth":95,"text":7336,"children":8454},[8455,8456,8457,8458,8459,8460,8461],{"id":7339,"depth":319,"text":7340},{"id":7457,"depth":319,"text":7458},{"id":7537,"depth":319,"text":7538},{"id":7853,"depth":319,"text":7854},{"id":8036,"depth":319,"text":8037},{"id":8119,"depth":319,"text":8120},{"id":8306,"depth":319,"text":8307},"2025-04-25","Go was designed at Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson to improve programming productivity in an era of multicore, networked machines and large codebases.",null,{},"\u002Fblogs\u002Fgolang-getting-started",{"title":6319,"description":8463},"blogs\u002Fgolang-getting-started\u002Findex",[2961,2962,6467,8470,8471,6314,6315],"golang","cloud","wI6FTyHnjv3R8FTIinA8Er38keVqLE8tFpfcR7aX8Jc",{"id":8474,"title":6235,"body":8475,"date":9613,"description":9614,"draft":1693,"extension":1694,"image":8464,"meta":9615,"navigation":977,"path":6234,"seo":9616,"stem":9617,"tags":9618,"__hash__":9619},"blogs\u002Fblogs\u002Fvirtualization_containers_and_role_of_docker_in_it\u002Findex.md",{"type":8,"value":8476,"toc":9594},[8477,8480,8483,8487,8490,8493,8498,8502,8505,8512,8515,8518,8521,8530,8534,8537,8540,8543,8547,8550,8588,8601,8605,8610,8613,8616,8621,8624,8635,8640,8643,8651,8656,8659,8670,8673,8675,8679,8888,8892,8962,8970,8978,9000,9009,9040,9072,9082,9100,9105,9117,9127,9135,9340,9345,9361,9369,9373,9486,9491,9496,9500,9509,9511,9562,9568,9571,9591],[11,8478,8479],{},"Docker is just a tool in your toolbox which can help you in your development lifecycle and make you a better software developer.",[11,8481,8482],{},"You can still do everything without it but in the hard way.",[63,8484,8486],{"id":8485},"what-to-expect-from-this-blog-post","What to expect from this blog post?",[11,8488,8489],{},"In this blog post, I will discuss a little bit about Virtualization, Containers and where it used before diving deep into detailed instructions on using Docker.",[11,8491,8492],{},"I will explain about Docker images, running Docker containers, Docker networking, Docker volumes and how it all works.",[11,8494,8495],{},[39,8496],{"alt":2031,"src":8497},"\u002Fimages\u002Fblogs\u002Fvirtualization_containers_and_role_of_docker_in_it\u002Fdocker.png",[63,8499,8501],{"id":8500},"why-docker-and-containers","Why docker and containers ?",[11,8503,8504],{},"If you go back 20–30 years, you had a hardware and installed operating system (Kernel and UI) on top of that. To run an application, we had to compile the code and sort all application dependencies. If we needed another application or more capacity to accommodate application workload hikes, we had to purchase new hardware, do installation, and configuration.",[11,8506,8507,8508,8511],{},"Virtualization added one additional layer between the hardware and operating system called ",[149,8509,8510],{},"hypervisor",". It allowed users to run multiple isolated applications on virtual machines with their OS.",[11,8513,8514],{},"While virtualization improved resource utilization by allowing multiple virtual machines (VMs) to run on a single physical server, it still had some inefficiencies. Each VM required its own full operating system, consuming significant resources (CPU, memory, and storage). Boot times were slow, and managing multiple VMs became complex.",[11,8516,8517],{},"Containers addressed these challenges by introducing a lightweight and efficient way to package and run applications. Unlike VMs, containers share the same operating system kernel while keeping applications isolated from one another. This eliminates the overhead of running multiple OS instances and results in faster startup times, better performance, and improved scalability.",[11,8519,8520],{},"Containers encapsulate everything an application needs—code, runtime, libraries, and dependencies—ensuring that it runs consistently across different environments, whether on a developer’s laptop, a test server, or in production.",[11,8522,8523,8527],{},[39,8524],{"alt":8525,"src":8526},"containers-hypervisor","\u002Fimages\u002Fblogs\u002Fvirtualization_containers_and_role_of_docker_in_it\u002Fcontainers-hypervisor.png",[3479,8528,8529],{},"Figure 2: Hypervisor and Containers",[44,8531,8533],{"id":8532},"so-what-is-docker","So what is docker ?",[11,8535,8536],{},"It is a container technology which help to bundle software and it's dependencies togather for running consistently across different environments.",[11,8538,8539],{},"In simple words, docker is a way to package softwares so they can run on any machines (Windows, mac and linux)",[11,8541,8542],{},"Docker revolutionized the way we build software by making microservice-based application development possible.",[63,8544,8546],{"id":8545},"where-is-docker-used-today","Where is Docker Used Today ?",[11,8548,8549],{},"Since its launch, Docker has become an industry-standard technology for containerization. It is widely used across various domains, including:",[21,8551,8552,8558,8564,8570,8576,8582],{},[24,8553,8554,8557],{},[149,8555,8556],{},"Software Development & DevOps:"," Enables faster development cycles, CI\u002FCD pipelines, and efficient testing environments.",[24,8559,8560,8563],{},[149,8561,8562],{},"Cloud Computing:"," Powers containerized applications in cloud platforms like AWS, Google Cloud, and Azure.",[24,8565,8566,8569],{},[149,8567,8568],{},"Microservices Architecture:"," Helps developers break applications into smaller, manageable services that can scale independently.",[24,8571,8572,8575],{},[149,8573,8574],{},"Edge Computing & IoT:"," Facilitates lightweight deployments on edge devices and embedded systems.",[24,8577,8578,8581],{},[149,8579,8580],{},"Big Data & AI\u002FML:"," Used for containerizing machine learning models and data pipelines for scalability.",[24,8583,8584,8587],{},[149,8585,8586],{},"Enterprise Applications:"," Modernizes legacy applications by running them in isolated, portable containers.",[11,8589,8590,8598],{},[1566,8591,8594],{"href":8592,"rel":8593},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=CZ3wIuvmHeM",[1570],[39,8595],{"alt":8596,"src":8597},"Netflix Microservice Architecture","\u002Fimages\u002Fblogs\u002Fvirtualization_containers_and_role_of_docker_in_it\u002Fnetflix-architecture.png",[3479,8599,8600],{},"Figure 3: Netflix Microservice Architecture",[63,8602,8604],{"id":8603},"docker-at-scale-real-world-use-cases","Docker at Scale – Real World Use Cases",[339,8606,8607],{},[24,8608,8609],{},"Google – Running Billions of Containers Per Week",[11,8611,8612],{},"Google runs all its services including Search, Gmail, YouTube, and Maps on containers.\nThey deploy over 2 billion containers per week, making Google one of the largest container users globally.",[11,8614,8615],{},"Their internal system, Borg, inspired Kubernetes, which now runs Docker containers worldwide.",[339,8617,8618],{"start":95},[24,8619,8620],{},"Netflix – Streaming to millions of Users with Docker",[11,8622,8623],{},"Netflix has a microservices architecture where thousands of services run in containers. Using Docker, they can:",[21,8625,8626,8629,8632],{},[24,8627,8628],{},"Deploy updates thousands of times per day with zero downtime.",[24,8630,8631],{},"Scale instantly during peak traffic (e.g., Stranger Things premieres).",[24,8633,8634],{},"Ensure a seamless experience for 250M+ users worldwide.",[339,8636,8637],{"start":319},[24,8638,8639],{},"PayPal – Cutting Deployment Time by 90%",[11,8641,8642],{},"PayPal migrated from VMs to Docker containers and reduced software deployment time from hours to minutes. By using Docker, PayPal improved:",[21,8644,8645,8648],{},[24,8646,8647],{},"Resource utilization, saving on infrastructure costs.",[24,8649,8650],{},"Developer agility, allowing teams to ship features 3x faster.",[339,8652,8653],{"start":328},[24,8654,8655],{},"SpaceX – Docker in Rocket Launch Simulations",[11,8657,8658],{},"SpaceX uses Docker to simulate rocket launches and run AI-powered navigation systems. Containers help:",[21,8660,8661,8664,8667],{},[24,8662,8663],{},"Test rocket software in isolated, reproducible environments.",[24,8665,8666],{},"Ensure mission-critical software runs identically across all systems.",[24,8668,8669],{},"Scale computing power as needed for complex calculations.",[11,8671,8672],{},"These examples show that Docker isn’t just a tool. it’s a critical infrastructure component powering the world’s largest applications.",[4240,8674],{},[44,8676,8678],{"id":8677},"concepts-in-docker","Concepts in docker",[339,8680,8681,8705,8726,8756,8783,8818,8872],{},[24,8682,8683,8686,8702,8704],{},[149,8684,8685],{},"Image",[21,8687,8688],{},[24,8689,8690,8691],{},"A Docker Image is a blueprint for a container. It includes:\n",[21,8692,8693,8696,8699],{},[24,8694,8695],{},"The application code",[24,8697,8698],{},"All dependencies (libraries, runtime, configurations)",[24,8700,8701],{},"Instructions to run the app (like a Dockerfile)",[5967,8703],{},"Example: An image can be Ubuntu, Nginx, or a custom Node.js app.",[24,8706,8707,8710],{},[149,8708,8709],{},"Container",[21,8711,8712],{},[24,8713,8714,8715,8717,8718],{},"A container is a running instance of an image. It is lightweight, isolated, and can be created, started, stopped, or deleted.",[5967,8716],{},"Think of it like this:",[21,8719,8720,8723],{},[24,8721,8722],{},"Image = Recipe",[24,8724,8725],{},"Container = Cooked dish",[24,8727,8728,8731],{},[149,8729,8730],{},"Dockerfile",[21,8732,8733],{},[24,8734,8735,8736,8753,8755],{},"A Dockerfile is a text file with a set of instructions to create a Docker image.\nIt defines:",[21,8737,8738,8741,8744,8747],{},[24,8739,8740],{},"Base image (e.g., FROM python:3.10)",[24,8742,8743],{},"Dependencies (e.g., RUN apt-get install)",[24,8745,8746],{},"Application code (e.g., COPY . \u002Fapp)",[24,8748,8749,8750,4150],{},"Start command (e.g., CMD ",[81,8751,8752],{},"\"python\", \"app.py\"",[5967,8754],{},"This ensures consistent builds across different environments.",[24,8757,8758,8761],{},[149,8759,8760],{},"Docker Hub",[21,8762,8763,8766],{},[24,8764,8765],{},"Docker Hub is a public registry where you can find and share Docker images. Think of it as GitHub for Docker images.",[24,8767,8768,8769],{},"Example: You can pull a ready-made Nginx image by running:\n",[71,8770,8772],{"className":73,"code":8771,"language":75,"meta":76,"style":76},"docker pull nginx\n",[78,8773,8774],{"__ignoreMap":76},[81,8775,8776,8778,8781],{"class":83,"line":84},[81,8777,2044],{"class":87},[81,8779,8780],{"class":101}," pull",[81,8782,2065],{"class":101},[24,8784,8785,8788],{},[149,8786,8787],{},"Volume",[21,8789,8790,8793],{},[24,8791,8792],{},"A Docker Volume is a persistent storage mechanism for containers. It ensures that data remains even if the container stops or restarts.",[24,8794,8795,8796],{},"Example: Running a MySQL database container with a volume:\n",[71,8797,8799],{"className":73,"code":8798,"language":75,"meta":76,"style":76},"docker run -d -v mysql-data:\u002Fvar\u002Flib\u002Fmysql mysql:latest\n",[78,8800,8801],{"__ignoreMap":76},[81,8802,8803,8805,8807,8810,8812,8815],{"class":83,"line":84},[81,8804,2044],{"class":87},[81,8806,2047],{"class":101},[81,8808,8809],{"class":91}," -d",[81,8811,2644],{"class":91},[81,8813,8814],{"class":101}," mysql-data:\u002Fvar\u002Flib\u002Fmysql",[81,8816,8817],{"class":101}," mysql:latest\n",[24,8819,8820,8823],{},[149,8821,8822],{},"Network",[21,8824,8825,8839],{},[24,8826,8827,8828],{},"Docker provides different networking options for containers to communicate with each other and the outside world:\n",[21,8829,8830,8833,8836],{},[24,8831,8832],{},"Bridge (default, for isolated containers)",[24,8834,8835],{},"Host (shares the host’s network)",[24,8837,8838],{},"Overlay (for multi-host networking in Swarm)",[24,8840,8841,8842],{},"Example: Running a container on a specific network:\n",[71,8843,8845],{"className":73,"code":8844,"language":75,"meta":76,"style":76},"docker network create my_network\ndocker run -d --network=my_network nginx\n",[78,8846,8847,8859],{"__ignoreMap":76},[81,8848,8849,8851,8854,8856],{"class":83,"line":84},[81,8850,2044],{"class":87},[81,8852,8853],{"class":101}," network",[81,8855,5061],{"class":101},[81,8857,8858],{"class":101}," my_network\n",[81,8860,8861,8863,8865,8867,8870],{"class":83,"line":95},[81,8862,2044],{"class":87},[81,8864,2047],{"class":101},[81,8866,8809],{"class":91},[81,8868,8869],{"class":91}," --network=my_network",[81,8871,2065],{"class":101},[24,8873,8874,8877],{},[149,8875,8876],{},"Docker Compose",[21,8878,8879,8885],{},[24,8880,8881,8882,8884],{},"Docker Compose allows you to define multi-container applications in a single ",[78,8883,842],{}," file.",[24,8886,8887],{},"It simplifies the deployment of complex applications with multiple services.",[44,8889,8891],{"id":8890},"docker-installation-on-linux","Docker installation on Linux",[21,8893,8894,8912,8946],{},[24,8895,4520,8896],{},[71,8897,8898],{"className":73,"code":4523,"language":75,"meta":76,"style":76},[78,8899,8900],{"__ignoreMap":76},[81,8901,8902,8904,8906,8908,8910],{"class":83,"line":84},[81,8903,4530],{"class":87},[81,8905,4533],{"class":91},[81,8907,4536],{"class":101},[81,8909,4540],{"class":4539},[81,8911,4543],{"class":87},[24,8913,4546,8914,8916],{},[78,8915,1231],{},[71,8917,8918],{"className":73,"code":4551,"language":75,"meta":76,"style":76},[78,8919,8920,8928,8940],{"__ignoreMap":76},[81,8921,8922,8924,8926],{"class":83,"line":84},[81,8923,1231],{"class":87},[81,8925,4560],{"class":101},[81,8927,4563],{"class":101},[81,8929,8930,8932,8934,8936,8938],{"class":83,"line":95},[81,8931,1231],{"class":87},[81,8933,4570],{"class":101},[81,8935,4573],{"class":91},[81,8937,4576],{"class":101},[81,8939,4579],{"class":859},[81,8941,8942,8944],{"class":83,"line":319},[81,8943,4584],{"class":87},[81,8945,4563],{"class":101},[24,8947,4589,8948,4593,8950],{},[78,8949,4592],{},[71,8951,8952],{"className":73,"code":4596,"language":75,"meta":76,"style":76},[78,8953,8954],{"__ignoreMap":76},[81,8955,8956,8958,8960],{"class":83,"line":84},[81,8957,2044],{"class":87},[81,8959,2047],{"class":101},[81,8961,4607],{"class":101},[63,8963,8965,8966,8969],{"id":8964},"running-a-nodejs-in-docker-from-terminal","Running a ",[78,8967,8968],{},"nodejs"," in docker from terminal",[339,8971,8972],{},[24,8973,4902,8974,8977],{},[78,8975,8976],{},"index.js"," file with the following code",[71,8979,8983],{"className":8980,"code":8981,"language":8982,"meta":76,"style":76},"language-js shiki shiki-themes github-light","console.log(\"Hello world\")\n","js",[78,8984,8985],{"__ignoreMap":76},[81,8986,8987,8990,8993,8995,8998],{"class":83,"line":84},[81,8988,8989],{"class":859},"console.",[81,8991,8992],{"class":87},"log",[81,8994,5855],{"class":859},[81,8996,8997],{"class":101},"\"Hello world\"",[81,8999,7170],{"class":859},[339,9001,9002],{"start":95},[24,9003,9004,9005,9008],{},"Run the ",[78,9006,9007],{},"node"," image",[71,9010,9012],{"className":73,"code":9011,"language":75,"meta":76,"style":76},"docker run -it --rm -v .\u002F:\u002Fapp -w \u002Fapp node:alpine3.21 sh\n",[78,9013,9014],{"__ignoreMap":76},[81,9015,9016,9018,9020,9022,9024,9026,9029,9032,9035,9038],{"class":83,"line":84},[81,9017,2044],{"class":87},[81,9019,2047],{"class":101},[81,9021,2116],{"class":91},[81,9023,2050],{"class":91},[81,9025,2644],{"class":91},[81,9027,9028],{"class":101}," .\u002F:\u002Fapp",[81,9030,9031],{"class":91}," -w",[81,9033,9034],{"class":101}," \u002Fapp",[81,9036,9037],{"class":101}," node:alpine3.21",[81,9039,4543],{"class":101},[21,9041,9042,9048,9054,9060,9066],{},[24,9043,9044,9047],{},[78,9045,9046],{},"run"," : create and run container from docker image",[24,9049,9050,9053],{},[78,9051,9052],{},"-it"," : starts a interactive shell",[24,9055,9056,9059],{},[78,9057,9058],{},"--rm",": remove the container after user exits the shell",[24,9061,9062,9065],{},[78,9063,9064],{},"-v","  : set the volume in container for sharing host files inside it",[24,9067,9068,9071],{},[78,9069,9070],{},"-w","  : sets the current working directory",[339,9073,9074],{"start":319},[24,9075,9076,9077,4893,9079,6482],{},"Check ",[78,9078,9007],{},[78,9080,9081],{},"npm",[71,9083,9085],{"className":73,"code":9084,"language":75,"meta":76,"style":76},"node -v\nnpm -v\n",[78,9086,9087,9094],{"__ignoreMap":76},[81,9088,9089,9091],{"class":83,"line":84},[81,9090,9007],{"class":87},[81,9092,9093],{"class":91}," -v\n",[81,9095,9096,9098],{"class":83,"line":95},[81,9097,9081],{"class":87},[81,9099,9093],{"class":91},[339,9101,9102],{"start":328},[24,9103,9104],{},"Run the javascript file",[71,9106,9108],{"className":73,"code":9107,"language":75,"meta":76,"style":76},"node index.js\n",[78,9109,9110],{"__ignoreMap":76},[81,9111,9112,9114],{"class":83,"line":84},[81,9113,9007],{"class":87},[81,9115,9116],{"class":101}," index.js\n",[63,9118,8965,9120,4893,9123,9126],{"id":9119},"running-a-mysql-and-phpmyadmin-setup-in-docker-using-docker-compose",[78,9121,9122],{},"MySQL",[78,9124,9125],{},"phpmyadmin"," setup in docker using docker compose",[339,9128,9129],{},[24,9130,4902,9131,9134],{},[78,9132,9133],{},"docker-compose.yaml"," file and paste the below content",[71,9136,9138],{"className":846,"code":9137,"language":848,"meta":76,"style":76},"services:\n  mysql:\n    image: mysql:9.2\n    container_name: mysql\n    restart: always\n    environment:\n      MYSQL_ROOT_PASSWORD: RootPassword\n      MYSQL_DATABASE: my_database\n      MYSQL_USER: govind\n      MYSQL_PASSWORD: GovindPassword\n    ports:\n      - \"3306:3306\"\n    volumes:\n      - mysql_data:\u002Fvar\u002Flib\u002Fmysql\n\n  phpmyadmin:\n    image: phpmyadmin:5.2\n    container_name: phpmyadmin\n    restart: always\n    environment:\n      PMA_HOST: mysql\n    ports:\n      - \"8000:80\"\n    depends_on:\n      - mysql\n\nvolumes:\n  mysql_data:\n",[78,9139,9140,9146,9152,9161,9170,9180,9186,9195,9204,9213,9222,9228,9235,9241,9247,9251,9258,9267,9276,9284,9290,9299,9305,9312,9318,9324,9328,9334],{"__ignoreMap":76},[81,9141,9142,9144],{"class":83,"line":84},[81,9143,868],{"class":855},[81,9145,871],{"class":859},[81,9147,9148,9150],{"class":83,"line":95},[81,9149,876],{"class":855},[81,9151,871],{"class":859},[81,9153,9154,9156,9158],{"class":83,"line":319},[81,9155,883],{"class":855},[81,9157,860],{"class":859},[81,9159,9160],{"class":101},"mysql:9.2\n",[81,9162,9163,9166,9168],{"class":83,"line":328},[81,9164,9165],{"class":855},"    container_name",[81,9167,860],{"class":859},[81,9169,1014],{"class":101},[81,9171,9172,9175,9177],{"class":83,"line":891},[81,9173,9174],{"class":855},"    restart",[81,9176,860],{"class":859},[81,9178,9179],{"class":101},"always\n",[81,9181,9182,9184],{"class":83,"line":899},[81,9183,894],{"class":855},[81,9185,871],{"class":859},[81,9187,9188,9190,9192],{"class":83,"line":910},[81,9189,902],{"class":855},[81,9191,860],{"class":859},[81,9193,9194],{"class":101},"RootPassword\n",[81,9196,9197,9199,9201],{"class":83,"line":921},[81,9198,913],{"class":855},[81,9200,860],{"class":859},[81,9202,9203],{"class":101},"my_database\n",[81,9205,9206,9208,9210],{"class":83,"line":931},[81,9207,924],{"class":855},[81,9209,860],{"class":859},[81,9211,9212],{"class":101},"govind\n",[81,9214,9215,9217,9219],{"class":83,"line":942},[81,9216,934],{"class":855},[81,9218,860],{"class":859},[81,9220,9221],{"class":101},"GovindPassword\n",[81,9223,9224,9226],{"class":83,"line":950},[81,9225,1060],{"class":855},[81,9227,871],{"class":859},[81,9229,9230,9232],{"class":83,"line":959},[81,9231,953],{"class":859},[81,9233,9234],{"class":101},"\"3306:3306\"\n",[81,9236,9237,9239],{"class":83,"line":967},[81,9238,945],{"class":855},[81,9240,871],{"class":859},[81,9242,9243,9245],{"class":83,"line":974},[81,9244,953],{"class":859},[81,9246,956],{"class":101},[81,9248,9249],{"class":83,"line":981},[81,9250,978],{"emptyLinePlaceholder":977},[81,9252,9253,9256],{"class":83,"line":989},[81,9254,9255],{"class":855},"  phpmyadmin",[81,9257,871],{"class":859},[81,9259,9260,9262,9264],{"class":83,"line":999},[81,9261,883],{"class":855},[81,9263,860],{"class":859},[81,9265,9266],{"class":101},"phpmyadmin:5.2\n",[81,9268,9269,9271,9273],{"class":83,"line":1006},[81,9270,9165],{"class":855},[81,9272,860],{"class":859},[81,9274,9275],{"class":101},"phpmyadmin\n",[81,9277,9278,9280,9282],{"class":83,"line":1017},[81,9279,9174],{"class":855},[81,9281,860],{"class":859},[81,9283,9179],{"class":101},[81,9285,9286,9288],{"class":83,"line":1028},[81,9287,894],{"class":855},[81,9289,871],{"class":859},[81,9291,9292,9295,9297],{"class":83,"line":1037},[81,9293,9294],{"class":855},"      PMA_HOST",[81,9296,860],{"class":859},[81,9298,1014],{"class":101},[81,9300,9301,9303],{"class":83,"line":1047},[81,9302,1060],{"class":855},[81,9304,871],{"class":859},[81,9306,9307,9309],{"class":83,"line":1057},[81,9308,953],{"class":859},[81,9310,9311],{"class":101},"\"8000:80\"\n",[81,9313,9314,9316],{"class":83,"line":1065},[81,9315,1092],{"class":855},[81,9317,871],{"class":859},[81,9319,9320,9322],{"class":83,"line":1073},[81,9321,953],{"class":859},[81,9323,1014],{"class":101},[81,9325,9326],{"class":83,"line":1081},[81,9327,978],{"emptyLinePlaceholder":977},[81,9329,9330,9332],{"class":83,"line":1089},[81,9331,1126],{"class":855},[81,9333,871],{"class":859},[81,9335,9336,9338],{"class":83,"line":1097},[81,9337,1134],{"class":855},[81,9339,871],{"class":859},[339,9341,9342],{"start":95},[24,9343,9344],{},"Run the below command",[71,9346,9348],{"className":73,"code":9347,"language":75,"meta":76,"style":76},"docker compose up -d\n",[78,9349,9350],{"__ignoreMap":76},[81,9351,9352,9354,9357,9359],{"class":83,"line":84},[81,9353,2044],{"class":87},[81,9355,9356],{"class":101}," compose",[81,9358,1173],{"class":101},[81,9360,1176],{"class":91},[339,9362,9363],{"start":319},[24,9364,2071,9365,9368],{},[78,9366,9367],{},"localhost:8000"," in your browser",[63,9370,9372],{"id":9371},"how-docker-works-internally","How Docker Works Internally",[339,9374,9375,9394,9433],{},[24,9376,9377,9380,9382,9383],{},[149,9378,9379],{},"Docker Architecture",[5967,9381],{},"Docker follows a client-server architecture with three main components:",[21,9384,9385,9388,9391],{},[24,9386,9387],{},"Docker Client ( CLI or API that sends commands (docker run, docker build) to the Docker daemon. )",[24,9389,9390],{},"Docker Daemon ( A background service (dockerd) that manages containers, images, volumes, and networks. )",[24,9392,9393],{},"Docker Registry ( A repository like Docker Hub where images are stored and pulled from. )",[24,9395,9396,9399],{},[149,9397,9398],{},"Docker Image & Container",[21,9400,9401,9417],{},[24,9402,9403,9406],{},[149,9404,9405],{},"Docker Image",[21,9407,9408,9411,9414],{},[24,9409,9410],{},"A read-only template containing everything needed to run an application (OS, dependencies, app code).",[24,9412,9413],{},"Built using a Dockerfile.",[24,9415,9416],{},"Can be stored in a registry and shared.",[24,9418,9419,9422],{},[149,9420,9421],{},"Docker Container",[21,9423,9424,9427,9430],{},[24,9425,9426],{},"A running instance of an image.",[24,9428,9429],{},"Uses UnionFS (OverlayFS, AUFS, etc.) for efficient layered storage.",[24,9431,9432],{},"Isolated from the host using namespaces and cgroups.",[24,9434,9435,9438,9440,9441],{},[149,9436,9437],{},"How Docker Runs a Container",[5967,9439],{},"When you run docker run node, Docker performs these steps:",[339,9442,9443,9449,9469,9475],{},[24,9444,9445,9446,9448],{},"Pulls the Image",[5967,9447],{},"Checks local storage; if not found, pulls from Docker Hub.",[24,9450,9451,9452],{},"Creates a Container",[21,9453,9454,9457,9460,9463,9466],{},[24,9455,9456],{},"Assigns a unique container ID.",[24,9458,9459],{},"Sets up a filesystem using UnionFS (copy-on-write layers).",[24,9461,9462],{},"Allocates namespaces for isolation (PID, NET, MNT, IPC, UTS).",[24,9464,9465],{},"Applies cgroups to limit CPU & memory usage.",[24,9467,9468],{},"Creates a virtual network interface (bridge mode by default).",[24,9470,9471,9472,9474],{},"Executes the Process",[5967,9473],{},"Runs the specified command (e.g., node app.js).",[24,9476,9477,9478],{},"Manages Lifecycle",[21,9479,9480,9483],{},[24,9481,9482],{},"When stopped, the container remains.",[24,9484,9485],{},"When removed (docker rm), the container’s writable layer is deleted.",[1874,9487,9488],{},[11,9489,9490],{},"Namespaces are a feature of the Linux kernel that partition kernel resources such that one set of processes sees one set of resources, while another set of processes sees a different set of resources.",[1874,9492,9493],{},[11,9494,9495],{},"In Linux, cgroups (control groups) are a kernel feature that allows administrators to limit, account for, and isolate the resource usage (CPU, memory, disk I\u002FO, network bandwidth) of a collection of processes",[63,9497,9499],{"id":9498},"alternatives","Alternatives",[21,9501,9502],{},[24,9503,9504],{},[1566,9505,9508],{"href":9506,"rel":9507},"https:\u002F\u002Fpodman.io\u002F",[1570],"Podman",[63,9510,2909],{"id":2908},[21,9512,9513,9521,9529,9536],{},[24,9514,9515,9516],{},"Public container registry ",[1566,9517,9520],{"href":9518,"rel":9519},"https:\u002F\u002Fhub.docker.com\u002F",[1570],"hub.docker.com",[24,9522,9523,9524],{},"A simple terminal UI for both docker and docker-compose ",[1566,9525,9528],{"href":9526,"rel":9527},"https:\u002F\u002Fgithub.com\u002Fjesseduffield\u002Flazydocker",[1570],"Lazydocker",[24,9530,9531],{},[1566,9532,9535],{"href":9533,"rel":9534},"https:\u002F\u002Fwww.youtube.com\u002Fplaylist?list=PLy7NrYWoggjwPggqtFsI_zMAwvG0SqYCb",[1570],"Docker Playlist",[24,9537,9538,9539],{},"YouTube Channels\n",[21,9540,9541,9548,9555],{},[24,9542,9543],{},[1566,9544,9547],{"href":9545,"rel":9546},"https:\u002F\u002Fwww.youtube.com\u002F@TechWorldwithNana",[1570],"TechWorld with Nana",[24,9549,9550],{},[1566,9551,9554],{"href":9552,"rel":9553},"https:\u002F\u002Fwww.youtube.com\u002F@KodeKloud",[1570],"KodeKloud",[24,9556,9557],{},[1566,9558,9561],{"href":9559,"rel":9560},"https:\u002F\u002Fwww.youtube.com\u002F@MarcelDempers",[1570],"That DevOps Guy",[1874,9563,9564],{},[63,9565,9567],{"id":9566},"recommendation","Recommendation",[11,9569,9570],{},"If you really want to know in deep how docker containers works then building is the best way to learn.",[11,9572,9573,9578,9579,9584,9585,9590],{},[1566,9574,9577],{"href":9575,"rel":9576},"https:\u002F\u002Fwww.lizrice.com",[1570],"Liz rice"," a Software engineer and a member of ",[1566,9580,9583],{"href":9581,"rel":9582},"https:\u002F\u002Fwww.cncf.io\u002F",[1570],"CNCF's Governing Board"," shows ",[1566,9586,9589],{"href":9587,"rel":9588},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=8fi7uSYlOdc",[1570],"Building a container from scratch in Go"," in a 40 min video.",[1631,9592,9593],{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .shJU0, html code.shiki .shJU0{--shiki-default:#22863A}",{"title":76,"searchDepth":95,"depth":95,"links":9595},[9596,9597,9598,9602,9603],{"id":8485,"depth":319,"text":8486},{"id":8500,"depth":319,"text":8501},{"id":8532,"depth":95,"text":8533,"children":9599},[9600,9601],{"id":8545,"depth":319,"text":8546},{"id":8603,"depth":319,"text":8604},{"id":8677,"depth":95,"text":8678},{"id":8890,"depth":95,"text":8891,"children":9604},[9605,9607,9609,9610,9611,9612],{"id":8964,"depth":319,"text":9606},"Running a nodejs in docker from terminal",{"id":9119,"depth":319,"text":9608},"Running a MySQL and phpmyadmin setup in docker using docker compose",{"id":9371,"depth":319,"text":9372},{"id":9498,"depth":319,"text":9499},{"id":2908,"depth":319,"text":2909},{"id":9566,"depth":319,"text":9567},"2025-04-01","How virtualization works, what containers are, and why Docker changed the way we build and ship software — explained from first principles with practical examples.",{},{"title":6235,"description":9614},"blogs\u002Fvirtualization_containers_and_role_of_docker_in_it\u002Findex",[2961,2962,2044,2963],"sMfmjDw-LjjkO5-VnmiMJx6vaHrVvpkyQNtN61KTygE",{"id":9621,"title":9622,"body":9623,"date":9913,"description":9914,"draft":1693,"extension":1694,"image":8464,"meta":9915,"navigation":977,"path":9916,"seo":9917,"stem":9918,"tags":9919,"__hash__":9921},"blogs\u002Fblogs\u002Ftcp_udp\u002Findex.md","Understanding TCP and UDP: Key Networking Protocols",{"type":8,"value":9624,"toc":9905},[9625,9628,9632,9635,9646,9650,9653,9664,9668,9675,9686,9693,9717,9721,9728,9733,9740,9752,9764,9780,9798,9802,9818,9830,9837,9841,9869,9879,9883,9886,9902],[11,9626,9627],{},"When it comes to network communication, two key protocols come into play: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). Both serve different purposes, and understanding their differences is crucial for building efficient communication systems.",[63,9629,9631],{"id":9630},"tcp-reliable-connection-oriented-communication","TCP: Reliable, Connection-Oriented Communication",[11,9633,9634],{},"TCP is all about reliability. It establishes a connection between client and server, ensuring every packet of data arrives safely and in order. This makes it ideal for use cases like:",[21,9636,9637,9640,9643],{},[24,9638,9639],{},"Web Browsing: Ensures data (like HTML, CSS, images) is loaded correctly.",[24,9641,9642],{},"File Transfers: Guarantees the complete and accurate delivery of files.",[24,9644,9645],{},"Emails: Makes sure all parts of the email reach the recipient.",[63,9647,9649],{"id":9648},"udp-fast-connection-less-communication","UDP: Fast, Connection-Less Communication",[11,9651,9652],{},"UDP, on the other hand, is all about speed. It sends data without establishing a connection, making it faster but less reliable than TCP. This is perfect for scenarios where real-time data is more important than complete accuracy:",[21,9654,9655,9658,9661],{},[24,9656,9657],{},"Video Streaming: Minimal delay is critical, even if some data is lost.",[24,9659,9660],{},"Online Gaming: Quick updates matter more than occasional packet loss.",[24,9662,9663],{},"Voice-over-IP (VoIP): Prioritizes continuous voice flow over packet delivery accuracy.",[63,9665,9667],{"id":9666},"project-setup","Project setup",[339,9669,9670],{},[24,9671,9672,152],{},[149,9673,9674],{},"Requirements",[21,9676,9677],{},[24,9678,9679,9680,9685],{},"Install ",[1566,9681,9684],{"href":9682,"rel":9683},"https:\u002F\u002Fnodejs.org\u002F",[1570],"Node.js"," (v20.17.0 recommended).",[339,9687,9688],{"start":95},[24,9689,9690,152],{},[149,9691,9692],{},"Clone the Project",[71,9694,9696],{"className":73,"code":9695,"language":75,"meta":76,"style":76},"git clone https:\u002F\u002Fgithub.com\u002F9ovindyadav\u002Fl4_servers.git && cd l4_servers\n",[78,9697,9698],{"__ignoreMap":76},[81,9699,9700,9703,9706,9709,9712,9714],{"class":83,"line":84},[81,9701,9702],{"class":87},"git",[81,9704,9705],{"class":101}," clone",[81,9707,9708],{"class":101}," https:\u002F\u002Fgithub.com\u002F9ovindyadav\u002Fl4_servers.git",[81,9710,9711],{"class":859}," && ",[81,9713,2618],{"class":91},[81,9715,9716],{"class":101}," l4_servers\n",[63,9718,9720],{"id":9719},"tcp-server","TCP Server",[339,9722,9723],{},[24,9724,9725],{},[149,9726,9727],{},"About",[21,9729,9730],{},[24,9731,9732],{},"This is a connection-oriented server, ensuring reliable communication between the client and server.",[339,9734,9735],{"start":95},[24,9736,9737],{},[149,9738,9739],{},"Run the TCP Server:",[71,9741,9743],{"className":73,"code":9742,"language":75,"meta":76,"style":76},"node tcp_server.js\n",[78,9744,9745],{"__ignoreMap":76},[81,9746,9747,9749],{"class":83,"line":84},[81,9748,9007],{"class":87},[81,9750,9751],{"class":101}," tcp_server.js\n",[339,9753,9754],{"start":319},[24,9755,9756,9759],{},[149,9757,9758],{},"Connect to the TCP Server:",[21,9760,9761],{},[24,9762,9763],{},"From another terminal or system, use:",[71,9765,9767],{"className":73,"code":9766,"language":75,"meta":76,"style":76},"telnet localhost 8000\n",[78,9768,9769],{"__ignoreMap":76},[81,9770,9771,9774,9777],{"class":83,"line":84},[81,9772,9773],{"class":87},"telnet",[81,9775,9776],{"class":101}," localhost",[81,9778,9779],{"class":91}," 8000\n",[21,9781,9782,9793],{},[24,9783,9784,9785],{},"After the connection is established:\n",[21,9786,9787,9790],{},[24,9788,9789],{},"Write a message in the terminal.",[24,9791,9792],{},"The message will be displayed in the server terminal.",[24,9794,9795,9797],{},[149,9796,1833],{},"  If the server crashes, the connection will be lost.",[63,9799,9801],{"id":9800},"udp-server","UDP Server",[339,9803,9804,9813],{},[24,9805,9806,9808],{},[149,9807,9727],{},[21,9809,9810],{},[24,9811,9812],{},"This is a connection-less server, offering fast, but potentially unreliable communication.",[24,9814,9815],{},[149,9816,9817],{},"Run the UDP Server:",[71,9819,9821],{"className":73,"code":9820,"language":75,"meta":76,"style":76},"node udp_server.js\n",[78,9822,9823],{"__ignoreMap":76},[81,9824,9825,9827],{"class":83,"line":84},[81,9826,9007],{"class":87},[81,9828,9829],{"class":101}," udp_server.js\n",[339,9831,9832],{"start":319},[24,9833,9834],{},[149,9835,9836],{},"Connect to the UDP Server:",[21,9838,9839],{},[24,9840,9763],{},[71,9842,9844],{"className":73,"code":9843,"language":75,"meta":76,"style":76},"echo \"Hii\" | nc -w1 -u localhost 8001\n",[78,9845,9846],{"__ignoreMap":76},[81,9847,9848,9850,9853,9855,9858,9861,9864,9866],{"class":83,"line":84},[81,9849,4662],{"class":91},[81,9851,9852],{"class":101}," \"Hii\"",[81,9854,4540],{"class":4539},[81,9856,9857],{"class":87}," nc",[81,9859,9860],{"class":91}," -w1",[81,9862,9863],{"class":91}," -u",[81,9865,9776],{"class":101},[81,9867,9868],{"class":91}," 8001\n",[21,9870,9871],{},[24,9872,9873,9874],{},"After sending a message:\n",[21,9875,9876],{},[24,9877,9878],{},"The message will appear in the server terminal.",[63,9880,9882],{"id":9881},"learning-resource","Learning Resource",[11,9884,9885],{},"For a deeper dive into building these servers with Node.js, I found this tutorial really helpful:",[21,9887,9888,9896],{},[24,9889,9890,9891],{},"YouTube video: ",[1566,9892,9895],{"href":9893,"rel":9894},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=1acKGwbby-E&feature=youtu.be",[1570],"Building TCP and UDP servers with NodeJS",[24,9897,9898,9899],{},"Blog Post : ",[1566,9900,9901],{"href":76},"Understanding TCP and UDP",[1631,9903,9904],{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}",{"title":76,"searchDepth":95,"depth":95,"links":9906},[9907,9908,9909,9910,9911,9912],{"id":9630,"depth":319,"text":9631},{"id":9648,"depth":319,"text":9649},{"id":9666,"depth":319,"text":9667},{"id":9719,"depth":319,"text":9720},{"id":9800,"depth":319,"text":9801},{"id":9881,"depth":319,"text":9882},"2024-09-29","A clear explanation of TCP and UDP — how they differ, when to use each, and how these transport-layer protocols power everything from web browsing to video streaming.",{},"\u002Fblogs\u002Ftcp_udp",{"title":9622,"description":9914},"blogs\u002Ftcp_udp\u002Findex",[2961,2962,9702,9920],"github","LAkDoiUmFz-SolzGgCKQaiUwyrOfaQJYVnJggbnjSQY",{"id":9923,"title":9924,"body":9925,"date":10445,"description":10446,"draft":1693,"extension":1694,"image":10447,"meta":10448,"navigation":977,"path":10449,"seo":10450,"stem":10451,"tags":10452,"__hash__":10456},"blogs\u002Fblogs\u002Funixtime\u002Findex.md","Behind the Scenes: How Computers Keep Track of Time",{"type":8,"value":9926,"toc":10437},[9927,9930,9933,9937,9940,9946,9949,9952,9957,9961,9975,9978,9981,9984,9987,9990,9993,9996,9999,10003,10007,10015,10019,10027,10083,10087,10090,10096,10099,10110,10113,10116,10119,10122,10136,10140,10143,10146,10149,10153,10174,10177,10180,10203,10209,10217,10224,10228,10231,10267,10271,10277,10284,10302,10309,10315,10333,10337,10344,10397,10405,10411,10429,10431,10434],[11,9928,9929],{},"Time at it's simplest is just a series of increasing seconds.",[11,9931,9932],{},"However, keeping track of time across the world is a much more difficult practice. Let’s look at the basics of how time works and then we will see ways how we manage it in computers.",[63,9934,9936],{"id":9935},"understanding-utc","Understanding UTC",[11,9938,9939],{},"Coordinated Universal Time or UTC is the primary time standard by which the world regulates clocks and time. UTC, or Coordinated Universal Time, isn’t an actual time zone, but it is a time standard. It doesn’t change for Daylight Saving, and all other time zones are measured in their relation to UTC.",[11,9941,9942],{},[39,9943],{"alt":9944,"src":9945},"Alt text for the image","\u002Fimages\u002Fblogs\u002Funixtime\u002FWorld_Time_Zones_Map.png",[11,9947,9948],{},"Time zones around the world are expressed using positive or negative offsets from UTC which has a range of UTC-12 to UTC+14.",[11,9950,9951],{},"India and Shri lanka uses Indian standard time ( IST ) which is offset UTC+5:30 i am 5 hours 30 minutes ahead of UTC.",[11,9953,9954],{},[39,9955],{"alt":9944,"src":9956},"\u002Fimages\u002Fblogs\u002Funixtime\u002F5f423d29-ad85-4f46-a91e-51f2f78368e9.avif",[63,9958,9960],{"id":9959},"how-computers-record-time","How Computers record time",[21,9962,9963,9966,9969,9972],{},[24,9964,9965],{},"In computing, an epoch is a fixed date and time used as a reference from which a computer measures system time.",[24,9967,9968],{},"it’s an arbitrary date with no real meaning.",[24,9970,9971],{},"For Unix systems it is - 01 jan 1970 00:00:00 UTC",[24,9973,9974],{},"For Windows it is - 01 jan 1601 00:00:00 UTC",[11,9976,9977],{},"The Unix time 0 is exactly midnight UTC on 1 January 1970, with Unix time incrementing by 1 for every second after this.",[11,9979,9980],{},"Each day in this kind of system is about 24 x 60 x 60 = 86,400 seconds long.",[11,9982,9983],{},"Today when i am writing this article it is 19 Nov 2023 3:53 PM and the unix time is 1700389351 seconds .",[11,9985,9986],{},"So for computers time is nothing but a incremented integer value .",[11,9988,9989],{},"For precise time measurement computers uses other systems like PTSS designed by engineers synced with some atomic clock.",[11,9991,9992],{},"So a question comes in mind how do we read those big integer values to human readbale format . Well that's where programming languages come for our help we programmers format these number's to human readable format so that we do not have to count how many seconds have passed . it's overall an abstraction to complex tech used to measure time.",[11,9994,9995],{},"On Unix-like systems, the computer keeps its clock in UTC and applies an offset based on your time zone. like if UTC time is 1,700,389,351 then for indian public software would have to add 5.5 x 60 x 60 = 19800 to UTC time to get Indian standard time.",[11,9997,9998],{},"In Windows, the system clock is stored as your local time i.e for Indian public it is already UTC+5:30 .",[63,10000,10002],{"id":10001},"largest-date-in-computer","Largest date in computer",[777,10004,10006],{"id":10005},"for-32-bit-operating-system","For 32 bit Operating system",[21,10008,10009,10012],{},[24,10010,10011],{},"largest integer value is 2^32 - 1 which is 4,294,967,295 .",[24,10013,10014],{},"So largest date possible is 19 Jan 2038 , after that value will overflow and we have to recaliberate it for 32bit OS.",[777,10016,10018],{"id":10017},"for-64-bit-operating-system","For 64 bit Operating system",[21,10020,10021,10024],{},[24,10022,10023],{},"largest integer value is 2^64 - 1 which is 18,446,744,073,709,551,615 .",[24,10025,10026],{},"So largest date possible is 21 July 2554 , which is really really far away so currently we don't have to worry about 64bit OS.",[10028,10029,10030,10047],"table",{},[10031,10032,10033],"thead",{},[10034,10035,10036,10041,10044],"tr",{},[10037,10038,10040],"th",{"align":10039},"center","Current unix time",[10037,10042,10043],{"align":10039},"32 bit OS largest integer",[10037,10045,10046],{"align":10039},"64 bit OS largest integer",[10048,10049,10050,10061,10072],"tbody",{},[10034,10051,10052,10055,10058],{},[10053,10054],"td",{"align":10039},[10053,10056,10057],{"align":10039},"2^32 - 1",[10053,10059,10060],{"align":10039},"2^64 - 1",[10034,10062,10063,10066,10069],{},[10053,10064,10065],{"align":10039},"1,700,389,351",[10053,10067,10068],{"align":10039},"4,294,967,295",[10053,10070,10071],{"align":10039},"18,446,744,073,709,551,615",[10034,10073,10074,10077,10080],{},[10053,10075,10076],{"align":10039},"19 Nov 2023",[10053,10078,10079],{"align":10039},"19 Jan 2038",[10053,10081,10082],{"align":10039},"21 July 2554",[63,10084,10086],{"id":10085},"network-time-protocol-ntp","Network time protocol ( NTP )",[11,10088,10089],{},"Network Time Protocol (NTP) is an internet protocol used to synchronize with computer clock time sources in a network.",[11,10091,10092],{},[39,10093],{"alt":10094,"src":10095},"Stratum-hierarchy-of-time-servers-and-sources","\u002Fimages\u002Fblogs\u002Funixtime\u002FStratum-hierarchy-of-time-servers-and-sources.png",[11,10097,10098],{},"How does NTP work?",[339,10100,10101,10104,10107],{},[24,10102,10103],{},"The NTP client initiates a time-request exchange with the NTP server.",[24,10105,10106],{},"The client is then able to calculate the link delay and its local offset and adjust its local clock to match the clock at the server's computer.",[24,10108,10109],{},"As a rule, six exchanges over a period of about five to 10 minutes are required to initially set the clock.",[11,10111,10112],{},"Once synchronized, the client updates the clock about once every 10 minutes, usually requiring only a single message exchange, in addition to client-server synchronization. This transaction occurs via User Datagram Protocol (UDP) on port 123.",[11,10114,10115],{},"There are thousands of NTP servers around the world. They have access to highly precise atomic clocks and Global Positioning System clocks.",[11,10117,10118],{},"What are stratum levels?",[11,10120,10121],{},"Degrees of separation from the UTC source are defined as strata. The various strata include the following :",[21,10123,10124,10127,10130,10133],{},[24,10125,10126],{},"Stratum 0. A reference clock receives true time from a dedicated transmitter or satellite navigation system. It is categorized as stratum 0.",[24,10128,10129],{},"Stratum 1. A device is directly linked to the reference clock.",[24,10131,10132],{},"Stratum 2. A device receives its time from a stratum 1 computer.",[24,10134,10135],{},"Stratum 3. A device receives its time from a stratum 2 computer.",[63,10137,10139],{"id":10138},"working-with-time-in-php","Working with time in PHP",[11,10141,10142],{},"So after a long time learning about time we finally know that computers store dates and times as timestamps because it is easier to manipulate an integer.",[11,10144,10145],{},"For example, to add one day to a timestamp, it simply adds the number of seconds to the timestamp.",[11,10147,10148],{},"PHP provides some helpful functions that manipulate timestamps effectively.",[777,10150,10152],{"id":10151},"getting-the-current-time","Getting the current time",[71,10154,10158],{"className":10155,"code":10156,"language":10157,"meta":76,"style":76},"language-php shiki shiki-themes github-light","\u003C?php\n\necho time(); \u002F\u002F 1700389351\n","php",[78,10159,10160,10165,10169],{"__ignoreMap":76},[81,10161,10162],{"class":83,"line":84},[81,10163,10164],{},"\u003C?php\n",[81,10166,10167],{"class":83,"line":95},[81,10168,978],{"emptyLinePlaceholder":977},[81,10170,10171],{"class":83,"line":319},[81,10172,10173],{},"echo time(); \u002F\u002F 1700389351\n",[11,10175,10176],{},"The return value is a big integer that represents the number of seconds since Epoch.",[11,10178,10179],{},"To make the time human-readable, you use the date() function. For example:",[71,10181,10183],{"className":10155,"code":10182,"language":10157,"meta":76,"style":76},"\u003C?php\n\n$current_time = time();\necho date('Y-m-d g:ia', $current_time); \u002F\u002F 2023-11-19 5:47am\n",[78,10184,10185,10189,10193,10198],{"__ignoreMap":76},[81,10186,10187],{"class":83,"line":84},[81,10188,10164],{},[81,10190,10191],{"class":83,"line":95},[81,10192,978],{"emptyLinePlaceholder":977},[81,10194,10195],{"class":83,"line":319},[81,10196,10197],{},"$current_time = time();\n",[81,10199,10200],{"class":83,"line":328},[81,10201,10202],{},"echo date('Y-m-d g:ia', $current_time); \u002F\u002F 2023-11-19 5:47am\n",[11,10204,6652,10205,10208],{},[78,10206,10207],{},"date()"," function has two parameters.",[21,10210,10211,10214],{},[24,10212,10213],{},"The first parameter specifies the date and time format.",[24,10215,10216],{},"The second parameter is an integer that specifies the timestamp.",[11,10218,10219,10220,10223],{},"Since the ",[78,10221,10222],{},"time()"," function returns a timestamp, we can add seconds to it.",[777,10225,10227],{"id":10226},"adding-and-subtracting-from-timestamp","Adding and subtracting from timestamp",[11,10229,10230],{},"The following example shows how to add a week to the current time:",[71,10232,10234],{"className":10155,"code":10233,"language":10157,"meta":76,"style":76},"\u003C?php\n\n$current_time = time();\n\u002F\u002F 7 days later\n$one_week_later =  $current_time + 7 * 24 * 60 * 60;\n\necho date('Y-m-d g:ia',$one_week_later);\n",[78,10235,10236,10240,10244,10248,10253,10258,10262],{"__ignoreMap":76},[81,10237,10238],{"class":83,"line":84},[81,10239,10164],{},[81,10241,10242],{"class":83,"line":95},[81,10243,978],{"emptyLinePlaceholder":977},[81,10245,10246],{"class":83,"line":319},[81,10247,10197],{},[81,10249,10250],{"class":83,"line":328},[81,10251,10252],{},"\u002F\u002F 7 days later\n",[81,10254,10255],{"class":83,"line":891},[81,10256,10257],{},"$one_week_later =  $current_time + 7 * 24 * 60 * 60;\n",[81,10259,10260],{"class":83,"line":899},[81,10261,978],{"emptyLinePlaceholder":977},[81,10263,10264],{"class":83,"line":910},[81,10265,10266],{},"echo date('Y-m-d g:ia',$one_week_later);\n",[777,10268,10270],{"id":10269},"timezone","Timezone",[11,10272,10273,10274,10276],{},"By default, the ",[78,10275,10222],{}," function returns the current time in the timezone specified in the PHP configuration file (php.ini).",[11,10278,10279,10280,10283],{},"To get the current timezone, you can use the ",[78,10281,10282],{},"date_default_timezone_get()"," function:",[71,10285,10287],{"className":10155,"code":10286,"language":10157,"meta":76,"style":76},"\u003C?php\n\necho(date_default_timezone_get());\n",[78,10288,10289,10293,10297],{"__ignoreMap":76},[81,10290,10291],{"class":83,"line":84},[81,10292,10164],{},[81,10294,10295],{"class":83,"line":95},[81,10296,978],{"emptyLinePlaceholder":977},[81,10298,10299],{"class":83,"line":319},[81,10300,10301],{},"echo(date_default_timezone_get());\n",[11,10303,10304,10305,10308],{},"To set a specific timezone, you use the ",[78,10306,10307],{},"date_default_timezone_set()",". It’s recommended that you use the UTC timezone.",[11,10310,10311,10312,10314],{},"The following shows how to use the ",[78,10313,10307],{}," function to set the current timezone to the UTC timezone:",[71,10316,10318],{"className":10155,"code":10317,"language":10157,"meta":76,"style":76},"\u003C?php\n\ndate_default_timezone_set('UTC');\n",[78,10319,10320,10324,10328],{"__ignoreMap":76},[81,10321,10322],{"class":83,"line":84},[81,10323,10164],{},[81,10325,10326],{"class":83,"line":95},[81,10327,978],{"emptyLinePlaceholder":977},[81,10329,10330],{"class":83,"line":319},[81,10331,10332],{},"date_default_timezone_set('UTC');\n",[777,10334,10336],{"id":10335},"making-a-unix-timestamp","Making a unix timestamp",[11,10338,10339,10340,10343],{},"To make a Unix timestamp, we use the ",[78,10341,10342],{},"mktime()"," function :",[71,10345,10347],{"className":10155,"code":10346,"language":10157,"meta":76,"style":76},"\u003C?php\n\nmktime(\n    int $hour,\n    int|null $minute = null,\n    int|null $second = null,\n    int|null $month = null,\n    int|null $day = null,\n    int|null $year = null\n): int|false\n",[78,10348,10349,10353,10357,10362,10367,10372,10377,10382,10387,10392],{"__ignoreMap":76},[81,10350,10351],{"class":83,"line":84},[81,10352,10164],{},[81,10354,10355],{"class":83,"line":95},[81,10356,978],{"emptyLinePlaceholder":977},[81,10358,10359],{"class":83,"line":319},[81,10360,10361],{},"mktime(\n",[81,10363,10364],{"class":83,"line":328},[81,10365,10366],{},"    int $hour,\n",[81,10368,10369],{"class":83,"line":891},[81,10370,10371],{},"    int|null $minute = null,\n",[81,10373,10374],{"class":83,"line":899},[81,10375,10376],{},"    int|null $second = null,\n",[81,10378,10379],{"class":83,"line":910},[81,10380,10381],{},"    int|null $month = null,\n",[81,10383,10384],{"class":83,"line":921},[81,10385,10386],{},"    int|null $day = null,\n",[81,10388,10389],{"class":83,"line":931},[81,10390,10391],{},"    int|null $year = null\n",[81,10393,10394],{"class":83,"line":942},[81,10395,10396],{},"): int|false\n",[11,10398,6652,10399,10401,10402,10404],{},[78,10400,10342],{}," function returns a Unix timestamp based on its arguments. If you omit an argument, ",[78,10403,10342],{}," function will use the current value according to the local date and time instead.",[11,10406,10407,10408,10410],{},"The following example shows how to use the ",[78,10409,10342],{}," function to show that Nov 19, 2023, is on a Sunday :",[71,10412,10414],{"className":10155,"code":10413,"language":10157,"meta":76,"style":76},"\u003C?php\n\necho 'Nov 19, 2023 is on a ' . date('l', mktime(0, 0, 0, 11, 19, 2023));\n",[78,10415,10416,10420,10424],{"__ignoreMap":76},[81,10417,10418],{"class":83,"line":84},[81,10419,10164],{},[81,10421,10422],{"class":83,"line":95},[81,10423,978],{"emptyLinePlaceholder":977},[81,10425,10426],{"class":83,"line":319},[81,10427,10428],{},"echo 'Nov 19, 2023 is on a ' . date('l', mktime(0, 0, 0, 11, 19, 2023));\n",[63,10430,1617],{"id":1616},[11,10432,10433],{},"Remember , time at it's simplest is just a series of increasing seconds for a computer geek.",[1631,10435,10436],{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":76,"searchDepth":95,"depth":95,"links":10438},[10439,10440,10441,10442,10443,10444],{"id":9935,"depth":319,"text":9936},{"id":9959,"depth":319,"text":9960},{"id":10001,"depth":319,"text":10002},{"id":10085,"depth":319,"text":10086},{"id":10138,"depth":319,"text":10139},{"id":1616,"depth":319,"text":1617},"2023-11-19","How computers track time internally — Unix timestamps, UTC, NTP, hardware clocks, and why the year 2038 problem matters. A deep dive into timekeeping in operating systems.","\u002Fimages\u002Fblogs\u002Funixtime\u002F73f71f22-e965-4a8f-870f-5b02f2b48e4a.avif",{},"\u002Fblogs\u002Funixtime",{"title":9924,"description":10446},"blogs\u002Funixtime\u002Findex",[10453,10454,10157,10455],"unix timestamp","utc","time","00tdwnEgLvW1jpDci_GmEZc2V6l1WT-mOuBhSgMUSf8",{"id":10458,"title":10459,"body":10460,"date":10731,"description":10732,"draft":1693,"extension":1694,"image":8464,"meta":10733,"navigation":977,"path":10734,"seo":10735,"stem":10736,"tags":10737,"__hash__":10738},"blogs\u002Fblogs\u002Fphp\u002Findex.md","PHP a general purpose programming language",{"type":8,"value":10461,"toc":10724},[10462,10465,10469,10477,10480,10483,10487,10490,10498,10502,10508,10511,10514,10547,10557,10560,10651,10655,10658,10672,10675,10680,10696,10699,10704,10716,10718,10721],[11,10463,10464],{},"Programming languages are formal systems designed for expressing computations. They are used to instruct computers and create software applications. There are numerous programming languages, each with its own syntax, semantics, and purposes.",[63,10466,10468],{"id":10467},"types-of-programming-languages","Types of programming languages",[339,10470,10471,10474],{},[24,10472,10473],{},"Domain specific like SQL",[24,10475,10476],{},"General purpose like C++, Java, Python, PHP.",[11,10478,10479],{},"The domain-specific languages are used within specific application domains. For example, SQL is a domain-specific language. It’s used mainly for querying data from relational databases. And SQL cannot be used for other purposes.",[11,10481,10482],{},"On the other hand, PHP is a general-purpose language because PHP can develop various applications but it is mainly used in web development.",[63,10484,10486],{"id":10485},"what-can-php-do","What can PHP do ?",[11,10488,10489],{},"PHP has two main applications :",[21,10491,10492,10495],{},[24,10493,10494],{},"Server side scripting - developing dynamic websites",[24,10496,10497],{},"Command line scripting - like python, we can run PHP script from command line to send mails or some admin tasks.",[63,10499,10501],{"id":10500},"how-php-works","How PHP works ?",[11,10503,10504],{},[39,10505],{"alt":10506,"src":10507},"How PHP works image","\u002Fimages\u002Fblogs\u002Fphp\u002FWhat-is-PHP-How-PHP-works.png",[11,10509,10510],{},"To Work with PHP we need to have following software installed",[11,10512,10513],{},"PHP",[21,10515,10516,10524,10531,10539],{},[24,10517,10518,10523],{},[1566,10519,10522],{"href":10520,"rel":10521},"https:\u002F\u002Fwww.apache.org\u002F",[1570],"Apache"," ( Web server )",[24,10525,10526,10530],{},[1566,10527,10513],{"href":10528,"rel":10529},"https:\u002F\u002Fwww.php.net\u002Fdownloads.php",[1570]," ( Zend Engine )",[24,10532,10533,10538],{},[1566,10534,10537],{"href":10535,"rel":10536},"https:\u002F\u002Fpecl.php.net",[1570],"PECL"," ( PHP Extension manager )",[24,10540,10541,10546],{},[1566,10542,10545],{"href":10543,"rel":10544},"https:\u002F\u002Fgetcomposer.org",[1570],"Composer"," ( PHP Library manager )",[11,10548,10549,10551,10552],{},[149,10550,1833],{}," To get started you can also try ",[1566,10553,10556],{"href":10554,"rel":10555},"https:\u002F\u002Ffrankenphp.dev\u002F",[1570],"FrankenPHP",[11,10558,10559],{},"After installation you will see something like this in your terminal",[71,10561,10563],{"className":73,"code":10562,"language":75,"meta":76,"style":76},"govind@debian:~$ php -v\nPHP 8.3.11 (cli) (built: Sep  2 2024 15:06:27) (NTS)\nCopyright (c) The PHP Group\nZend Engine v4.3.11, Copyright (c) Zend Technologies\n    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies\n",[78,10564,10565,10574,10607,10615,10632],{"__ignoreMap":76},[81,10566,10567,10569,10572],{"class":83,"line":84},[81,10568,6670],{"class":87},[81,10570,10571],{"class":101}," php",[81,10573,9093],{"class":91},[81,10575,10576,10578,10581,10584,10587,10590,10593,10596,10599,10602,10605],{"class":83,"line":95},[81,10577,10513],{"class":87},[81,10579,10580],{"class":91}," 8.3.11",[81,10582,10583],{"class":859}," (cli) (",[81,10585,10586],{"class":87},"built:",[81,10588,10589],{"class":101}," Sep",[81,10591,10592],{"class":91},"  2",[81,10594,10595],{"class":91}," 2024",[81,10597,10598],{"class":101}," 15:06:27",[81,10600,10601],{"class":859},") (",[81,10603,10604],{"class":87},"NTS",[81,10606,7170],{"class":859},[81,10608,10609,10612],{"class":83,"line":319},[81,10610,10611],{"class":87},"Copyright",[81,10613,10614],{"class":859}," (c) The PHP Group\n",[81,10616,10617,10620,10623,10626,10629],{"class":83,"line":328},[81,10618,10619],{"class":87},"Zend",[81,10621,10622],{"class":101}," Engine",[81,10624,10625],{"class":101}," v4.3.11,",[81,10627,10628],{"class":101}," Copyright",[81,10630,10631],{"class":859}," (c) Zend Technologies\n",[81,10633,10634,10637,10640,10643,10646,10648],{"class":83,"line":891},[81,10635,10636],{"class":87},"    with",[81,10638,10639],{"class":101}," Zend",[81,10641,10642],{"class":101}," OPcache",[81,10644,10645],{"class":101}," v8.3.11,",[81,10647,10628],{"class":101},[81,10649,10650],{"class":859}," (c), by Zend Technologies\n",[63,10652,10654],{"id":10653},"running-php-code","Running PHP code",[11,10656,10657],{},"First of all make a file named index.php and write some code in it as given below",[71,10659,10661],{"className":10155,"code":10660,"language":10157,"meta":76,"style":76},"\u003C?php\n    echo \"Hello world\";\n",[78,10662,10663,10667],{"__ignoreMap":76},[81,10664,10665],{"class":83,"line":84},[81,10666,10164],{},[81,10668,10669],{"class":83,"line":95},[81,10670,10671],{},"    echo \"Hello world\";\n",[11,10673,10674],{},"There is 2 ways by which you can run PHP code",[21,10676,10677],{},[24,10678,10679],{},"Serve on the web",[71,10681,10683],{"className":73,"code":10682,"language":75,"meta":76,"style":76},"  php -S localhost:8000\n",[78,10684,10685],{"__ignoreMap":76},[81,10686,10687,10690,10693],{"class":83,"line":84},[81,10688,10689],{"class":87},"  php",[81,10691,10692],{"class":91}," -S",[81,10694,10695],{"class":101}," localhost:8000\n",[11,10697,10698],{},"now go to the browser and type localhost:8000 in address bar",[21,10700,10701],{},[24,10702,10703],{},"On the Command line",[71,10705,10707],{"className":73,"code":10706,"language":75,"meta":76,"style":76},"  php index.php\n",[78,10708,10709],{"__ignoreMap":76},[81,10710,10711,10713],{"class":83,"line":84},[81,10712,10689],{"class":87},[81,10714,10715],{"class":101}," index.php\n",[63,10717,1617],{"id":1616},[11,10719,10720],{},"PHP continues to be a powerful and versatile language for both web and command-line applications. Its ability to dynamically generate content, combined with an extensive ecosystem of libraries and frameworks, makes it a popular choice for developers worldwide.",[1631,10722,10723],{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":76,"searchDepth":95,"depth":95,"links":10725},[10726,10727,10728,10729,10730],{"id":10467,"depth":319,"text":10468},{"id":10485,"depth":319,"text":10486},{"id":10500,"depth":319,"text":10501},{"id":10653,"depth":319,"text":10654},{"id":1616,"depth":319,"text":1617},"2023-11-11","Choosing a programming language often depends on the task at hand, the platform you are targeting, and your personal preferences.",{},"\u002Fblogs\u002Fphp",{"title":10459,"description":10732},"blogs\u002Fphp\u002Findex",[10157,2961,2962],"rZF_k9qJFNfo7T8MbXtXWnk8xDShS2xtiRJk_uxN0xE",{"id":10740,"title":10741,"body":10742,"date":10984,"description":10985,"draft":1693,"extension":1694,"image":8464,"meta":10986,"navigation":977,"path":10987,"seo":10988,"stem":10989,"tags":10990,"__hash__":10991},"blogs\u002Fblogs\u002Fgithub\u002Findex.md","Git and GitHub- Basic commands for beginners",{"type":8,"value":10743,"toc":10975},[10744,10747,10751,10754,10766,10770,10797,10801,10804,10826,10830,10833,10873,10877,10880,10885,10896,10935,10940,10947,10951,10956,10959,10964,10967,10969,10972],[11,10745,10746],{},"Git and GitHub have become indispensable tools for developers and teams working on software projects. Git is a distributed version control system, and GitHub is a web-based platform that enhances collaboration and code sharing. In this blog, we'll focus on four fundamental Git commands that every developer should know and expand on other essential topics related to Git and GitHub.",[63,10748,10750],{"id":10749},"_1-git-initialization-git-init","1. Git Initialization ( git init )",[11,10752,10753],{},"To start version controlling your project with Git, you first need to initialize a repository. The git init command creates a new Git repository in your project directory. It establishes a .git directory that tracks changes and manages your project's history.",[71,10755,10757],{"className":73,"code":10756,"language":75,"meta":76,"style":76},"git init\n",[78,10758,10759],{"__ignoreMap":76},[81,10760,10761,10763],{"class":83,"line":84},[81,10762,9702],{"class":87},[81,10764,10765],{"class":101}," init\n",[63,10767,10769],{"id":10768},"_2-adding-and-committing-git-add-and-git-commit","2. Adding and Committing ( git add and git commit )",[71,10771,10773],{"className":73,"code":10772,"language":75,"meta":76,"style":76},"git add .\ngit commit -m \"Your message here\"\n",[78,10774,10775,10785],{"__ignoreMap":76},[81,10776,10777,10779,10782],{"class":83,"line":84},[81,10778,9702],{"class":87},[81,10780,10781],{"class":101}," add",[81,10783,10784],{"class":101}," .\n",[81,10786,10787,10789,10792,10794],{"class":83,"line":95},[81,10788,9702],{"class":87},[81,10790,10791],{"class":101}," commit",[81,10793,4699],{"class":91},[81,10795,10796],{"class":101}," \"Your message here\"\n",[63,10798,10800],{"id":10799},"_3-managing-branches-git-branch","3. Managing Branches (git branch)",[11,10802,10803],{},"Branches are a vital part of Git workflows. They allow you to work on different features or bug fixes without affecting the main codebase. Use git branch to list existing branches and create new ones.",[71,10805,10807],{"className":73,"code":10806,"language":75,"meta":76,"style":76},"git branch\ngit branch feature-branch\n",[78,10808,10809,10816],{"__ignoreMap":76},[81,10810,10811,10813],{"class":83,"line":84},[81,10812,9702],{"class":87},[81,10814,10815],{"class":101}," branch\n",[81,10817,10818,10820,10823],{"class":83,"line":95},[81,10819,9702],{"class":87},[81,10821,10822],{"class":101}," branch",[81,10824,10825],{"class":101}," feature-branch\n",[63,10827,10829],{"id":10828},"_4-remote-repositories-git-remote","4. Remote Repositories (git remote)",[11,10831,10832],{},"Git allows you to collaborate with others by connecting your local repository to remote repositories, such as GitHub. The git remote command helps you manage remote connections.",[71,10834,10836],{"className":73,"code":10835,"language":75,"meta":76,"style":76},"git remote\ngit remote add origin \u003CGitHub repository URL>\n",[78,10837,10838,10845],{"__ignoreMap":76},[81,10839,10840,10842],{"class":83,"line":84},[81,10841,9702],{"class":87},[81,10843,10844],{"class":101}," remote\n",[81,10846,10847,10849,10852,10854,10857,10859,10862,10865,10868,10871],{"class":83,"line":95},[81,10848,9702],{"class":87},[81,10850,10851],{"class":101}," remote",[81,10853,10781],{"class":101},[81,10855,10856],{"class":101}," origin",[81,10858,5494],{"class":4539},[81,10860,10861],{"class":101},"GitHub",[81,10863,10864],{"class":101}," repository",[81,10866,10867],{"class":101}," UR",[81,10869,10870],{"class":859},"L",[81,10872,2372],{"class":4539},[63,10874,10876],{"id":10875},"beyond-the-basics","Beyond the Basics",[11,10878,10879],{},"While these four commands are fundamental, Git and GitHub offer much more:",[339,10881,10882],{},[24,10883,10884],{},"Pushing and Pulling (git push and git pull)",[11,10886,10887,10888,10891,10892,10895],{},"Use ",[78,10889,10890],{},"git push"," to send your local commits to a remote repository, and ",[78,10893,10894],{},"git pull"," to retrieve changes from a remote repository to your local project.",[71,10897,10899],{"className":73,"code":10898,"language":75,"meta":76,"style":76},"git push origin \u003Cbranch-name>\ngit pull origin \u003Cbranch-name>\n",[78,10900,10901,10919],{"__ignoreMap":76},[81,10902,10903,10905,10908,10910,10912,10915,10917],{"class":83,"line":84},[81,10904,9702],{"class":87},[81,10906,10907],{"class":101}," push",[81,10909,10856],{"class":101},[81,10911,5494],{"class":4539},[81,10913,10914],{"class":101},"branch-nam",[81,10916,5148],{"class":859},[81,10918,2372],{"class":4539},[81,10920,10921,10923,10925,10927,10929,10931,10933],{"class":83,"line":95},[81,10922,9702],{"class":87},[81,10924,8780],{"class":101},[81,10926,10856],{"class":101},[81,10928,5494],{"class":4539},[81,10930,10914],{"class":101},[81,10932,5148],{"class":859},[81,10934,2372],{"class":4539},[339,10936,10937],{"start":95},[24,10938,10939],{},"Cloning Repositories (git clone)",[11,10941,10942,10943,10946],{},"To create a local copy of a remote repository, use the ",[78,10944,10945],{},"git clone"," command. This is useful when starting to work on an existing project hosted on GitHub.",[63,10948,10950],{"id":10949},"authenticate-your-github-account-with-git-on-your-local-machine-to-work-seamlessly","Authenticate your Github account with git on your local machine to work seamlessly",[21,10952,10953],{},[24,10954,10955],{},"Github CLI tool",[11,10957,10958],{},"GitHub provides a command-line interface (CLI) tool that streamlines interactions with GitHub repositories and issues. It offers features like creating repositories, managing issues, and more.",[21,10960,10961],{},[24,10962,10963],{},"SSH Key Authentication",[11,10965,10966],{},"To enhance security and simplify access to your GitHub repositories, consider setting up SSH key authentication. This allows you to securely connect to your repositories without entering your credentials repeatedly.",[63,10968,1617],{"id":1616},[11,10970,10971],{},"Mastering these essential Git and GitHub commands will empower you to efficiently track changes, collaborate with others, and manage your projects effectively. Git and GitHub offer a plethora of features and capabilities that can greatly enhance your development workflow, making them invaluable tools for any software developer or team. Explore and experiment with these tools to harness their full potential.",[1631,10973,10974],{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}",{"title":76,"searchDepth":95,"depth":95,"links":10976},[10977,10978,10979,10980,10981,10982,10983],{"id":10749,"depth":319,"text":10750},{"id":10768,"depth":319,"text":10769},{"id":10799,"depth":319,"text":10800},{"id":10828,"depth":319,"text":10829},{"id":10875,"depth":319,"text":10876},{"id":10949,"depth":319,"text":10950},{"id":1616,"depth":319,"text":1617},"2023-10-27","Not a complete course for Git just basic 5 to 6 commands which i use every day",{},"\u002Fblogs\u002Fgithub",{"title":10741,"description":10985},"blogs\u002Fgithub\u002Findex",[2961,2962,9702,9920],"cfC_3rXg2P-MQrk6lktnPs0o7Q8xr92QbxLqw8JHqco",1782753863073]