<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Debug School: rakesh kumar</title>
    <description>The latest articles on Debug School by rakesh kumar (@rakeshdevcotocus_468).</description>
    <link>https://www.debug.school/rakeshdevcotocus_468</link>
    <image>
      <url>https://www.debug.school/images/WnjM0tj_qJIv1YRaHUFCcWCxLQyroc-__BJWYYD46DE/rs:fill:90:90/g:sm/mb:500000/ar:1/aHR0cHM6Ly93d3cu/ZGVidWcuc2Nob29s/L3VwbG9hZHMvdXNl/ci9wcm9maWxlX2lt/YWdlLzkvMzhjZTM3/NDAtZDA2NC00MmVh/LTk1MmMtODg2MGQ2/MGNhZGU1LmpwZWc</url>
      <title>Debug School: rakesh kumar</title>
      <link>https://www.debug.school/rakeshdevcotocus_468</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://www.debug.school/feed/rakeshdevcotocus_468"/>
    <language>en</language>
    <item>
      <title>How to Restore a Changed File with git checkout</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Sun, 27 Sep 2026 05:09:04 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/how-to-restore-a-changed-file-with-git-checkout-44bh</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/how-to-restore-a-changed-file-with-git-checkout-44bh</guid>
      <description>&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;shows the normal HolidayLandmark homepage. Earlier, requests to / returned the CERUTU4D gambling page, and a server search found cerutu4d inside&lt;/p&gt;

&lt;p&gt;Apache’s HolidayLandmark configuration points to hl-home. That explains why changing a file in this folder could change what visitors saw. The Git copy of index.php was reportedly clean, so the evidence points to a change in the deployed copy. It does not yet establish who made the change or how they gained write access.&lt;br&gt;
There is a second, urgent issue: the investigation reported that visitors could download /.env. The restored homepage does not prove that this exposure is fixed. Laravel warns that serving the project root can expose sensitive configuration files; its intended web entry point is public/index.php&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/rq9pymmcpnjvivyjhw74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/rq9pymmcpnjvivyjhw74.png" alt=" " width="1720" height="1096"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/7zfxtdy55f7h94s7mpcl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/7zfxtdy55f7h94s7mpcl.png" alt=" " width="1720" height="1096"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Investigation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo grep -RIlFi --binary-files=without-match 'cerutu4d' \
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/opt/lampp/htdocs/holiday-new/hl-home/index.php
/opt/lampp/htdocs/holiday-new/hl-home/blog/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -- index.php .htaccess
mv blog/index.html "$Q/blog-index.html.live"
php artisan optimize:clear
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/t9zk6mx2yrj2wlnhjw17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/t9zk6mx2yrj2wlnhjw17.png" alt=" " width="912" height="447"&gt;&lt;/a&gt;&lt;br&gt;
after running gitcheckout command i get&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/cpokpdwhfj4jh5s8ixiu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/cpokpdwhfj4jh5s8ixiu.png" alt=" " width="1891" height="887"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This replaces the current index.php and .htaccess with the versions in your current Git commit. That is why it could restore the homepage after those files were changed. It overwrites unsaved changes in those files, so check them first with git diff&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chatgpt.com/c/6ab89e76-0c1c-83e8-a317-edd1c5d8ba37" rel="noopener noreferrer"&gt;chatgpt&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How a Gambling Page Replaced My Laravel Homepage—and Why Restoring index.php Fixed It</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Sat, 26 Sep 2026 06:11:52 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/how-a-gambling-page-replaced-my-laravel-homepage-and-why-restoring-indexphp-fixed-it-64h</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/how-a-gambling-page-replaced-my-laravel-homepage-and-why-restoring-indexphp-fixed-it-64h</guid>
      <description>&lt;p&gt;&lt;strong&gt;What happened&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Where the problem was&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Why your commands made the homepage work&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Mitigation checklist&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What happened
&lt;/h2&gt;

&lt;p&gt;Your screenshot now shows the normal HolidayLandmark homepage. Earlier, requests to / returned the CERUTU4D gambling page, and a server search found cerutu4d inside:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo grep -RIlFi --binary-files=without-match 'cerutu4d' \
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
/opt/lampp/htdocs/holiday-new/hl-home/index.php
/opt/lampp/htdocs/holiday-new/hl-home/blog/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apache’s HolidayLandmark configuration points to hl-home. That explains why changing a file in this folder could change what visitors saw. The Git copy of index.php was reportedly clean, so the evidence points to a change in the deployed copy. It does not yet establish who made the change or how they gained write access.&lt;br&gt;
There is a second, urgent issue: the investigation reported that visitors could download /.env. The restored homepage does not prove that this exposure is fixed. Laravel warns that serving the project root can expose sensitive configuration files; its intended web entry point is public/index.php&lt;/p&gt;

&lt;p&gt;&lt;code&gt;There are two connected security failures:&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The live homepage was changed. Everyone requesting / receives the gambling page. The clean Git repository suggests the unwanted change is in the deployed files, but it does not tell us who changed them or how.&lt;/li&gt;
&lt;li&gt;Private Laravel files are reachable through the website. You report that .env is downloadable, along with artisan and composer.json. If the response contains the real .env file, treat every secret in it as exposed. Laravel specifically warns that serving the project root can expose sensitive configuration files.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Where the problem was
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/0b7vc7cqzamjye8jjnx1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/0b7vc7cqzamjye8jjnx1.png" alt=" " width="482" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/3la7yqzpfmaa32v2y2v1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/3la7yqzpfmaa32v2y2v1.png" alt=" " width="491" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/zqzngtiko72ek2tgwrp7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/zqzngtiko72ek2tgwrp7.png" alt=" " width="952" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/sd0enoj7bdwpfx6gyqpn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/sd0enoj7bdwpfx6gyqpn.png" alt=" " width="955" height="592"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Why your commands made the homepage work
&lt;/h2&gt;

&lt;p&gt;You ran:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -- index.php .htaccess
mv blog/index.html "$Q/blog-index.html.live"
php artisan optimize:clear

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/1z53o9n5rktc4avy7h3e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/1z53o9n5rktc4avy7h3e.png" alt=" " width="977" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/h1w5azg5cofud7ipuns3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/h1w5azg5cofud7ipuns3.png" alt=" " width="530" height="611"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mitigation checklist
&lt;/h2&gt;

&lt;p&gt;Fix it in this order&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Preserve evidence&lt;/strong&gt;
Keep private copies of the altered index.php and blog/index.html, their stat output, Apache access/error logs, and Git status. Do not delete the spam files before saving them; their timestamps and contents may help identify the entry point. CISA’s incident guidance calls for preserving evidence while responding. CISA&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Do kaam karne hain:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;access block karein&lt;/code&gt;: HolidayLandmark ke Apache virtual host mein diya gaya  rule lagane se visitors .env, artisan, composer.json aur composer.lock jaise filenames nahi khol paayenge. httpd -t configuration ki syntax check karta hai; uske baad Apache ko reload karke URLs test karne honge. Apache mein  aur Require all denied isi tarah file access control ke liye use hote hain. Apache HTTP Server Version 2.4&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Permanent layout fix karein&lt;/code&gt;: HolidayLandmark ka DocumentRoot Laravel ke public folder par set karein. Tab .env aur baaki project files web root ke bahar rahengi. Laravel requests ka intended entry point public/index.php hai. laravel.com&lt;br&gt;
/trips/ aur /blog/ ko pehle map karne ka matlab: pata karein ki ye URLs abhi kis folder, Apache Alias, ya Laravel route se chal rahe hain. Uske baad DocumentRoot badlein, taaki ye working pages accidentally band na ho jaayein.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/llppqkzncpr7ptcdzuk5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/llppqkzncpr7ptcdzuk5.png" alt=" " width="987" height="647"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/vbsw242vma55y1mgsf0s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/vbsw242vma55y1mgsf0s.png" alt=" " width="1036" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Stop public access to secrets immediately&lt;/strong&gt;
The lasting fix is to configure this Laravel application’s Apache DocumentRoot to the correct public directory, with the project and .env outside that web root. First map the current /trips/ and /blog/ routing so the change does not break them. Laravel documents public/index.php as its intended entry point. laravel.com
Until that layout is corrected, add an Apache access rule in the HolidayLandmark virtual host to deny the exposed filenames:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;FilesMatch "^(?:\.env(?:\..*)?|artisan|composer\.(?:json|lock))$"&amp;gt;
    Require all denied
&amp;lt;/FilesMatch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apache supports FilesMatch and Require all denied for this purpose. Check the configuration with sudo /opt/lampp/bin/httpd -t before reloading Apache, then confirm those URLs return 403 or 404. This filename rule is temporary protection; it does not make serving a Laravel project root safe. Apache HTTP Server Version 2.4&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Restore the clean homepage&lt;/strong&gt;
Since the Git version of index.php has reportedly been checked and is clean, restore that file only from the verified repository. Check blog/index.html separately: the earlier search found the spam term there too, even though /blog/ currently works. Restore it from a clean version if it is altered. Avoid git reset --hard or a broad pull on production; those can erase unrelated changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replace exposed credentials&lt;/strong&gt;
After blocking .env access, rotate the credentials listed in it: database users, Keycloak client secret, API/SMTP/storage keys, and any other active credentials. Review their access logs for misuse. Plan APP_KEY rotation carefully: Laravel uses it to decrypt application data, so changing it without a migration plan can affect sessions or encrypted values. laravel.com&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Find how the files were changed&lt;/strong&gt;
Use the saved file modification times to examine SSH logins, deployments, Apache requests, application logs, and writable directories around those times. Also check who can write to hl-home/index.php. A clean Git repository does not rule out a stolen SSH/deployment credential, an unsafe upload path, or an application vulnerability.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/69169fiskvfthtf56seo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/69169fiskvfthtf56seo.png" alt=" " width="920" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/evqi0wkzhvbjo165bv6e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/evqi0wkzhvbjo165bv6e.png" alt=" " width="1032" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chatgpt.com/c/6ab4cc9f-3b60-83e8-9fdb-a7329379a553" rel="noopener noreferrer"&gt;chatgpt&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>From Prompts to Production: An 8-Step Roadmap to AI Agent Architecture</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Fri, 25 Sep 2026 07:09:59 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/from-prompts-to-production-an-8-step-roadmap-to-ai-agent-architecture-26ig</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/from-prompts-to-production-an-8-step-roadmap-to-ai-agent-architecture-26ig</guid>
      <description>&lt;p&gt;An AI agent is an application that can use a language model to work toward a goal, choose from permitted tools, use information, and decide what to do next. A useful agent needs more than a good prompt: it needs reliable data, controlled access to tools, checks on its output, and a way to measure whether it completed the task.&lt;/p&gt;

&lt;p&gt;The screenshot presents eight stages, from prompt engineering through system design and career development. Here is a practical explanation of each stage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/40k5bnygi8foi0hlcjb2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/40k5bnygi8foi0hlcjb2.png" alt=" " width="577" height="822"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/ya7tuhnjqzodr4hik596.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/ya7tuhnjqzodr4hik596.png" alt=" " width="392" height="562"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prompt Engineering Foundations
&lt;/h2&gt;

&lt;p&gt;A prompt tells the model what task to perform and what a useful answer looks like. Start by stating the goal, giving relevant context, defining constraints, and specifying the output format.&lt;/p&gt;

&lt;p&gt;For example, “Summarize this order” is vague. A stronger instruction is: “Summarize this order for a delivery manager in three bullets: current status, delay reason, and next action. Use only the supplied order data.”&lt;/p&gt;

&lt;p&gt;Learn how to write clear instructions, supply a few examples when helpful, and revise a prompt after examining its failures. A system message can set application behavior, while the user message supplies the current task. Prompting is the first skill, but it cannot compensate for missing data or an unreliable workflow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/rp7hbite76rqt0hlro99.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/rp7hbite76rqt0hlro99.png" alt=" " width="645" height="605"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with LLMs and APIs
&lt;/h2&gt;

&lt;p&gt;The next step is calling a model from your application. Your FastAPI backend might receive a request, send the relevant information to a model API, validate the response, and return it to the frontend.&lt;/p&gt;

&lt;p&gt;Learn API authentication, request and response handling, timeouts, rate limits, token usage, and cost tracking. When your application needs a predictable response, use a defined JSON schema or structured output and validate the result before saving it or showing it to a user. Function calling and structured outputs are supported patterns for connecting model responses to application code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/kpo6edr08ichnbqjjho1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/kpo6edr08ichnbqjjho1.png" alt=" " width="616" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building AI-Powered Applications
&lt;/h2&gt;

&lt;p&gt;At this stage, the model becomes one part of a working product. Suppose you build a support assistant for HolidayLandmark. The user asks, “What is the cancellation policy for my trip?” The app must identify the relevant trip, retrieve the applicable policy, and produce an answer grounded in those records.&lt;/p&gt;

&lt;p&gt;Retrieval-augmented generation (RAG) is useful when answers depend on documents or records that are not reliably contained in the model itself. A typical flow is: store searchable content, retrieve relevant passages for the question, and provide those passages to the model. Evaluate whether retrieval found the right material before judging the final answer.&lt;/p&gt;

&lt;p&gt;A vector database is one possible retrieval component, not a requirement for every AI application. For a small, structured dataset, ordinary database queries may be simpler and more accurate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/z119k5lf5g58tq7bd4ob.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/z119k5lf5g58tq7bd4ob.png" alt=" " width="591" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tool Use and Function Calling
&lt;/h2&gt;

&lt;p&gt;Tools let the agent interact with application functions. Examples include get_order_status(order_id), search_trip_policy(query), or calculate_refund(booking_id).&lt;/p&gt;

&lt;p&gt;The model can request a tool call, but your application executes the function. The application should validate its arguments, check the user’s permissions, handle failures, and return the result to the model. Start with read-only tools; add actions such as changing a booking only when the workflow needs them.&lt;/p&gt;

&lt;p&gt;This is where a conversational assistant can begin doing useful work. It is also where permissions become critical: an agent should receive only the tools and access needed for its task. OWASP identifies excessive agent authority as a security risk.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/067h65kianetwf22o8if.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/067h65kianetwf22o8if.png" alt=" " width="625" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Agent Fundamentals
&lt;/h2&gt;

&lt;p&gt;A basic agent follows a loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Understand the goal → choose an action → use a tool → inspect the result → respond or continue.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, an order-support agent might read an order, check the latest delivery event, consult a delay policy, then explain the next step. It may need several tool calls, but each should serve the original request.&lt;/p&gt;

&lt;p&gt;Learn to set stopping conditions, limit tool calls, handle errors, and preserve only the context needed for the task. Distinguish conversation history from durable memory: saving a user preference or fact for future use requires an explicit design decision. Build and evaluate one capable agent before adding more agents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/vckiwlfghdoec8mlytzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/vckiwlfghdoec8mlytzu.png" alt=" " width="1386" height="895"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/6s59mzvpu9930be2dmow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/6s59mzvpu9930be2dmow.png" alt=" " width="1267" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Multi-Agent Systems and Orchestration
&lt;/h2&gt;

&lt;p&gt;A multi-agent system divides work between specialized agents. One might retrieve facts, another analyze them, and a coordinator combine their results. Orchestration defines who receives each task, what information they can access, and how the final answer is produced.&lt;/p&gt;

&lt;p&gt;This helps when tasks are genuinely independent or require different tools. It also introduces handoff errors, additional cost, and more decisions to inspect. Use multiple agents when a single agent with well-defined tools becomes difficult to manage or evaluate, not simply because the task has several steps.&lt;/p&gt;

&lt;p&gt;For consequential actions, an orchestration flow can pause for human review before an agent writes to a database, sends a message, or changes a booking.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/exy81jxflxqkfag81od9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/exy81jxflxqkfag81od9.png" alt=" " width="627" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Agent Architect Skills
&lt;/h2&gt;

&lt;p&gt;An architect designs the complete system around the model. That includes choosing where data comes from, deciding which operations the agent may perform, defining approval points, and planning for failures.&lt;/p&gt;

&lt;p&gt;A production design should answer concrete questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What happens when retrieval returns the wrong document?&lt;/li&gt;
&lt;li&gt;Can a tool change data without checking the user’s identity?&lt;/li&gt;
&lt;li&gt;What happens when the model API times out?&lt;/li&gt;
&lt;li&gt;How will you trace a wrong answer back to its inputs and tool calls?&lt;/li&gt;
&lt;li&gt;How will you test accuracy, latency, cost, and safety before release?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Prompt injection and excessive agency are documented risks, so the design must treat retrieved pages, documents, and tool results as potentially untrusted input.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/w5csx0i1zzu9l96b6pin.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/w5csx0i1zzu9l96b6pin.png" alt=" " width="605" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Career Path: Build Evidence Through Projects
&lt;/h2&gt;

&lt;p&gt;The screenshot suggests a progression from prompting to application development, agent development, solutions architecture, and technical leadership. Treat these as areas of responsibility, not guaranteed job titles or salary steps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/tbhwaomjjlnvxwq7x50v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/tbhwaomjjlnvxwq7x50v.png" alt=" " width="637" height="551"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A strong portfolio would show increasing scope:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A prompt-driven feature with measured output quality.&lt;/li&gt;
&lt;li&gt;A FastAPI application that calls a model and validates responses.&lt;/li&gt;
&lt;li&gt;A document or database assistant that retrieves and cites its source data.&lt;/li&gt;
&lt;li&gt;A tool-using agent with authentication, error handling, and traceable actions.&lt;/li&gt;
&lt;li&gt;A production design explaining permissions, evaluation, monitoring, cost, and failure recovery.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your existing FastAPI and backend experience gives you a practical starting point: connect an agent to a narrow feature in a product you understand, then measure whether it solves that feature’s real user problem.&lt;/p&gt;

&lt;p&gt;Colorful architecture: how a production agent works&lt;/p&gt;

&lt;p&gt;The diagram shows a possible single-agent application. The colored groups separate user interaction, application control, AI decisions, data access, and operational checks.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Check Whether It’s an Attack, an Out-of-Memory Crash, or a Full Disk</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Thu, 24 Sep 2026 13:00:35 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/how-to-check-whether-its-an-attack-an-out-of-memory-crash-or-a-full-disk-5b4p</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/how-to-check-whether-its-an-attack-an-out-of-memory-crash-or-a-full-disk-5b4p</guid>
      <description>&lt;p&gt;Repeated downtime does not by itself mean someone hacked the server. Failed SSH attempts and suspicious web requests are common on public servers; the key is whether anyone successfully logged in and what happened at the time of each outage.&lt;/p&gt;

&lt;p&gt;Run these read-only commands on the affected server. They do not delete logs or change settings.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Find when the server restarted or a service failed
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uptime
last -x reboot shutdown | head -30
sudo journalctl --list-boots
sudo journalctl -b -1 -p warning..alert --no-pager | tail -100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-b -1 means the previous boot. If it says there is no previous boot, that journal may not have been retained. journalctl can filter by boot and severity.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Look for memory, disk, and service problems
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo journalctl -k --since "7 days ago" --no-pager | rg -i 'out of memory|oom|killed process|no space left|I/O error|ext4'
df -h
free -h
sudo systemctl --failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your earlier screenshot mentioned no swap and possible OOM events, so the first command is especially useful. A failed service can indicate a crash or timeout; it is not automatically evidence of an attack.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Check SSH attempts and successful logins
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo journalctl --since "7 days ago" --no-pager | rg -i 'sshd.*(Failed password|Invalid user|Accepted password|Accepted publickey|session opened)' | tail -150
sudo zgrep -hEi 'sshd.*(Failed password|Invalid user|Accepted password|Accepted publickey)' /var/log/auth.log* | tail -150
last -ai | head -40
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Accepted password and Accepted publickey lines deserve closer attention: compare their user, IP address, and time with logins you recognize. Repeated Failed password lines alone show attempts, not successful access. Use whichever log source actually has records on your server.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Search XAMPP Apache logs for common probes&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First see which log files exist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find /opt/lampp/logs -maxdepth 2 -type f -printf '%p\n' | head -60
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, if /opt/lampp/logs/access_log and error_log exist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo rg -i -m 100 'wp-admin|wp-login|\.env|/vendor/phpunit|/cgi-bin|/server-status|/actuator|/\.git|/etc/passwd' /opt/lampp/logs/access_log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo rg -i -m 100 'AH[0-9]+|segfault|fatal|permission denied|server reached MaxRequestWorkers' /opt/lampp/logs/error_log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A request for .env or wp-admin indicates a probe, not proof it succeeded. Apache’s error log is also a key place to investigate why Apache stopped or failed to serve requests.&lt;/p&gt;

&lt;p&gt;Start by sending the output of sections 1 and 2, plus any unfamiliar Accepted SSH lines from section 3. You can mask public IPs if needed, but keep the timestamps, usernames, and message text so we can correlate them with the downtime.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chatgpt.com/c/6ab4d329-5ac8-83ee-9e03-cc4767cbb524" rel="noopener noreferrer"&gt;chat&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Add Swap Space on a Linux Server</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Thu, 24 Sep 2026 10:34:11 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/how-to-add-swap-space-on-a-linux-server-2o8d</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/how-to-add-swap-space-on-a-linux-server-2o8d</guid>
      <description>&lt;p&gt;A server can be running normally with gigabytes of free RAM, then lose its database a few seconds later. MySQL is killed and the site shows "Error establishing a database connection." Often the cause is a short memory spike on a server with no swap.&lt;/p&gt;

&lt;p&gt;This guide covers what swap is, why a server needs it, how much to add, and every command to create, check and resize it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is swap?
&lt;/h2&gt;

&lt;p&gt;Swap is disk space the Linux kernel can use as overflow memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RAM&lt;/strong&gt; is fast, and every running program lives there.&lt;br&gt;
&lt;strong&gt;Swap&lt;/strong&gt; is a file or partition on disk, much slower than RAM, used only when RAM runs short.&lt;br&gt;
When RAM fills up, the kernel moves memory pages that aren't being actively used, such as idle parts of programs or rarely touched data, from RAM into swap. That frees RAM for work that's actually happening.&lt;/p&gt;
&lt;h2&gt;
  
  
  What happens when there is no swap?
&lt;/h2&gt;

&lt;p&gt;When RAM runs out and there's no swap, the kernel has one option left: the OOM killer (Out-Of-Memory killer). It picks a process, usually the largest one, and kills it straight away to free memory.&lt;/p&gt;

&lt;p&gt;On a typical web server, the largest processes are the important ones:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MySQL / MariaDB / PostgreSQL&lt;/strong&gt;: the site loses its database&lt;br&gt;
&lt;strong&gt;Java apps (Keycloak, Elasticsearch, Jenkins)&lt;/strong&gt;: logins or search stop working&lt;br&gt;
&lt;strong&gt;PHP-FPM / Node&lt;/strong&gt;: requests start failing&lt;br&gt;
Nothing warns you. The process just disappears, and you find out when users complain.&lt;/p&gt;
&lt;h2&gt;
  
  
  What swap changes
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/j3wku0248cnh8k4eox5e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/j3wku0248cnh8k4eox5e.png" alt=" " width="612" height="247"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Swap is not extra RAM
&lt;/h2&gt;

&lt;p&gt;Swap is much slower than RAM. If a server uses swap heavily and all the time, it slows down. That's a sign it needs more RAM, and swap doesn't fix that. Swap is for short spikes, not steady load.&lt;/p&gt;

&lt;p&gt;The vm.swappiness setting controls how readily the kernel uses swap:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/m7k5vpetkzsehqyuxduj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/m7k5vpetkzsehqyuxduj.png" alt=" " width="652" height="195"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How much swap should you add?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/6tba57npmz0vgawup5s0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/6tba57npmz0vgawup5s0.png" alt=" " width="590" height="237"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Part 2: Check Your Current State
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;free -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/q0demc77vq8qbw36g7bd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/q0demc77vq8qbw36g7bd.png" alt=" " width="627" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check free disk space&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df -h /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Filesystem      Size  Used Avail Use% Mounted on
/dev/root       107G   92G   15G  87% /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure Avail stays comfortable after you subtract the swap size.&lt;/p&gt;

&lt;p&gt;Optional: has the OOM killer already struck?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dmesg -T | grep -iE "out of memory|killed process"
journalctl -k --since "30 days ago" | grep -iE "killed process"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lines like Killed process 1234 (mysqld) mean you've already been losing processes to memory spikes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 3: Add Swap (Step by Step)
&lt;/h2&gt;

&lt;p&gt;Run these as root, or put sudo in front of each.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: Create the swap file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fallocate -l 4G /swapfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If fallocate isn't supported on your filesystem, use dd:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dd if=/dev/zero of=/swapfile bs=1M count=4096
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Lock down permissions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod 600 /swapfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only root should be able to read swap, because it can contain pieces of memory such as passwords and session data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Format it as swap&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkswap /swapfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Turn it on&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;swapon /swapfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Swap is now active, with no reboot needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Keep it after a reboot&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep -q '/swapfile' /etc/fstab || echo '/swapfile none swap sw 0 0' &amp;gt;&amp;gt; /etc/fstab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The grep -q ... || part adds the line only if it isn't already there, so running the command twice won't create a duplicate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Set swappiness to 10&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sysctl vm.swappiness=10
echo 'vm.swappiness=10' &amp;gt; /etc/sysctl.d/99-swappiness.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line applies it now; the second keeps it after a reboot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 4: Verify Everything
&lt;/h2&gt;

&lt;p&gt;Run all four checks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;free -h
swapon --show
grep swap /etc/fstab
cat /proc/sys/vm/swappiness
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Expected output&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/htzfmxsndkx8xxnesmxf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/htzfmxsndkx8xxnesmxf.png" alt=" " width="512" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💡 Swap "used: 0B" is normal and good. It means RAM is enough right now. Swap only fills during a memory spike.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 5: Change the Swap Size
&lt;/h2&gt;

&lt;p&gt;Say you meant to create 4 GB but free -h shows 8.0Gi, or you want to grow or shrink it later.&lt;/p&gt;

&lt;p&gt;Check first that swap isn't heavily used, because swapoff has to move everything back into RAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;free -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then recreate it at the new size:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;swapoff /swapfile
rm /swapfile
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The /etc/fstab line and swappiness setting stay the same. Check again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;free -h
swapon --show
df -h /

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 6: Keep an Eye on It
&lt;/h2&gt;

&lt;p&gt;Watch swap usage over time&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;free -h
vmstat 5 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In vmstat, look at the si (swap in) and so (swap out) columns:&lt;/p&gt;

&lt;p&gt;Mostly 0: healthy; swap is only a safety net.&lt;br&gt;
Always above 0: the server is short of RAM. Add RAM, or reduce what's running.&lt;br&gt;
&lt;strong&gt;See which processes are using swap&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for f in /proc/[0-9]*/status; do
  awk '/^Name|^VmSwap/{printf "%s ", $2} END{print ""}' "$f" 2&amp;gt;/dev/null
done | awk '$2 &amp;gt; 0' | sort -k2 -rn | head
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remove swap completely&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;swapoff /swapfile
rm /swapfile
sed -i '\|^/swapfile |d' /etc/fstab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Check
free -h
swapon --show
df -h /

# Add 4 GB swap
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
grep -q '/swapfile' /etc/fstab || echo '/swapfile none swap sw 0 0' &amp;gt;&amp;gt; /etc/fstab

# Tune
sysctl vm.swappiness=10
echo 'vm.swappiness=10' &amp;gt; /etc/sysctl.d/99-swappiness.conf

# Verify
free -h
swapon --show
grep swap /etc/fstab
cat /proc/sys/vm/swappiness
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How to Fix a Cron Email Flood</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Thu, 24 Sep 2026 09:58:59 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/how-to-fix-a-cron-email-flood-51mc</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/how-to-fix-a-cron-email-flood-51mc</guid>
      <description>&lt;h2&gt;
  
  
  Why cron sends email
&lt;/h2&gt;

&lt;p&gt;When a cron job prints anything, whether normal output or an error, cron emails that text to the user who owns the crontab. On most servers nobody reads those emails. They pile up in a local mailbox:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/var/mail/root        (or /var/spool/mail/root)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A job that runs every minute and prints one line produces 1,440 emails a day. Several such jobs over a few months add up to gigabytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Check whether you have the problem
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -lh /var/mail/root

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-rw------- 1 root mail 1.7G Sep 24 10:15 /var/mail/root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anything above a few MB is worth looking into. Also check overall disk usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df -h /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Find which jobs are sending the mail&lt;/strong&gt;&lt;br&gt;
Count the emails:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep -c '^From ' /var/mail/root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Group them by the job that sent them. Cron puts the command in the subject line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep '^Subject:' /var/mail/root | sort | uniq -c | sort -rn | head -10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;48210 Subject: Cron &lt;a href="mailto:root@server"&gt;root@server&lt;/a&gt; /opt/scripts/site_check.sh&lt;br&gt;
 12030 Subject: Cron &lt;a href="mailto:root@server"&gt;root@server&lt;/a&gt; /bin/bash /root/disk-alert.sh&lt;br&gt;
The top entries are the ones to fix.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Find where those jobs are defined&lt;/strong&gt;&lt;br&gt;
Cron jobs can live in several places, so check all of them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;crontab -l                 # root's crontab
crontab -l -u ubuntu       # another user's crontab
cat /etc/crontab
ls /etc/cron.d/ &amp;amp;&amp;amp; cat /etc/cron.d/*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or search for the script name everywhere:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
grep -rn "site_check" /etc/crontab /etc/cron.d /var/spool/cron 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Redirect the output&lt;/strong&gt;&lt;br&gt;
Open the crontab:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;crontab -e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to change each job:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/kf2cn893yro4hkvwtbm8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/kf2cn893yro4hkvwtbm8.png" alt=" " width="612" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ending  What it does&lt;br&gt;
(nothing)   Output is emailed to the owner. This is the cause of the flood.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;/dev/null 2&amp;gt;&amp;amp;1 Output and errors are thrown away
&amp;gt;&amp;gt; /var/log/job.log 2&amp;gt;&amp;amp;1    Output and errors are added to a log file
What the symbols mean:

&amp;gt; sends normal output (stdout) to a file, replacing its contents
&amp;gt;&amp;gt; adds normal output to the end of a file
2&amp;gt;&amp;amp;1 sends errors (stderr) to the same place as normal output
/dev/null discards anything written to it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Frequent, low-value jobs (every minute, every 5 minutes): throw the output away.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* * * * *   /opt/scripts/site_check.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1
*/5 * * * * /bin/bash /root/disk-alert.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important, infrequent jobs such as backups: log the output so you can still see failures.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 3 * * 0 /bin/bash /opt/scripts/weekly-backup.sh &amp;gt;&amp;gt; /var/log/weekly-backup.log 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the log later with:&lt;/p&gt;

&lt;p&gt;tail -50 /var/log/weekly-backup.log&lt;br&gt;
Option: turn off cron mail for a whole crontab&lt;br&gt;
Add this as the first line of the crontab:&lt;/p&gt;

&lt;p&gt;MAILTO=""&lt;br&gt;
Cron then sends no email for any job in that file.&lt;/p&gt;

&lt;p&gt;⚠️ Watch out: some alert scripts work by printing a warning and relying on cron to email it. Adding /dev/null or MAILTO="" silences those alerts. Check the script with cat /path/to/script.sh. If it only uses echo, have it send the alert itself (mail, curl to Slack or Telegram, and so on) before you silence it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 5: Empty the mailbox
&lt;/h2&gt;

&lt;p&gt;Only do this after fixing the crontab. Otherwise it fills up again straight away.&lt;/p&gt;

&lt;p&gt;If you want, keep the most recent emails first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tail -n 2000 /var/mail/root &amp;gt; /root/last-cron-mail.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then empty the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;truncate -s 0 /var/mail/root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use truncate, not rm. truncate empties the file but keeps its owner and permissions, which the mail system relies on.&lt;/p&gt;

&lt;p&gt;Check the space came back:&lt;/p&gt;

&lt;p&gt;ls -lh /var/mail/root     # 0&lt;br&gt;
df -h /                   # more space available&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 6: Confirm the flood has stopped
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Wait 5-10 minutes, then check again&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -lh /var/mail/root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it's still 0 or a few KB, you're done. If it's growing, one job is still mailing. Run the Subject: count from Step 2 to see which one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick reference
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# 1. Check
ls -lh /var/mail/root

# 2. Find what's sending mail
grep '^Subject:' /var/mail/root | sort | uniq -c | sort -rn | head

# 3. Find the job
grep -rn "script-name" /etc/crontab /etc/cron.d /var/spool/cron

# 4. Fix it: add &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 (or &amp;gt;&amp;gt; logfile 2&amp;gt;&amp;amp;1)
crontab -e

# 5. Empty the mailbox
truncate -s 0 /var/mail/root

# 6. Check again after a few minutes
ls -lh /var/mail/root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Takeaway&lt;/strong&gt;&lt;br&gt;
Every cron job should say where its output goes. Leave that out and cron emails the output to a mailbox nobody reads, and it grows until the disk is full. As a rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Frequent jobs: &amp;gt;/dev/null 2&amp;gt;&amp;amp;1
Important jobs: &amp;gt;&amp;gt; /var/log/&amp;lt;job&amp;gt;.log 2&amp;gt;&amp;amp;1, and rotate those logs with logrotate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alert jobs: have the script send its own alert, and don't rely on cron mail&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Assertions in Unit, Functional, UI, and Performance Testing</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Mon, 21 Sep 2026 11:57:42 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/assertions-in-unit-functional-ui-and-performance-testing-1ia6</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/assertions-in-unit-functional-ui-and-performance-testing-1ia6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Unit testing assertion commands&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Functinal testing assertion commands&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;UI testing assertion commands&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Performance testing assertion commands&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Unit testing assertion commands
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;assertSame()&lt;/strong&gt; — exact value and type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertSame($expected, $actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertSame(
    ['confirmed', 'cancelled'],
    $transitions['pending']
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertEquals()&lt;/strong&gt; — equivalent value
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertEquals($expected, $actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertEquals(4500, $calculatedTripPrice);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For prices, prefer assertSame() when you also need to enforce the result’s type.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertTrue()&lt;/strong&gt; — condition must be true
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertTrue($condition);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertTrue($booking-&amp;gt;canBeCancelled());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertFalse()&lt;/strong&gt; — condition must be false
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertFalse($condition);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertFalse($completedBooking-&amp;gt;canBeCancelled());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertNull()&lt;/strong&gt; — value must be null
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertNull($actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertNull($booking-&amp;gt;cancelled_at);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertNotNull()&lt;/strong&gt; — value must exist
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertNotNull($actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertNotNull($confirmedBooking-&amp;gt;confirmed_at);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertEmpty()&lt;/strong&gt; — collection or value must be empty
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertEmpty($actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertEmpty($transitions['completed']);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertNotEmpty()&lt;/strong&gt; — collection or value must contain something
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertNotEmpty($actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertNotEmpty($availableTripDates);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertCount()&lt;/strong&gt; — exact number of items
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertCount($expectedCount, $actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertCount(3, $trip-&amp;gt;itineraryDays);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertContains()&lt;/strong&gt; — item appears in a collection
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertContains($expectedItem, $actualCollection);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertContains('confirmed', $transitions['pending']);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;11.** assertNotContains()** — item is absent from a collection&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertNotContains($unexpectedItem, $actualCollection);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertNotContains('confirmed', $transitions['cancelled']);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertArrayHasKey()&lt;/strong&gt; — array contains a key
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertArrayHasKey($key, $array);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertArrayHasKey('pending', $transitions);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertArrayNotHasKey()&lt;/strong&gt; — array does not contain a key
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertArrayNotHasKey($key, $array);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertArrayNotHasKey('deleted', $transitions);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertGreaterThan()&lt;/strong&gt; — actual value is larger
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertGreaterThan($minimum, $actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertGreaterThan(0, $trip-&amp;gt;availableSeats());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertLessThanOrEqual()&lt;/strong&gt; — actual value is at most the limit
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertLessThanOrEqual($maximum, $actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertLessThanOrEqual($trip-&amp;gt;capacity, $requestedGuestCount);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertInstanceOf()&lt;/strong&gt; — object has the expected class
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertInstanceOf($expectedClass, $actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertInstanceOf(Booking::class, $booking);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertIsArray()&lt;/strong&gt; — value must be an array
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertIsArray($actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
$this-&amp;gt;assertIsArray($trip-&amp;gt;getItinerary());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertIsInt()&lt;/strong&gt; — value must be an integer
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertIsInt($actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertIsInt($trip-&amp;gt;availableSeats());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertStringContainsString()&lt;/strong&gt; — text contains a phrase
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertStringContainsString($expectedText, $actualText);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertStringContainsString(
    'Royal Family Luxury Getaway',
    $trip-&amp;gt;title
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;assertMatchesRegularExpression()&lt;/strong&gt; — text matches a pattern
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertMatchesRegularExpression($pattern, $actualText);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;assertMatchesRegularExpression(
    '/^HL-[0-9]{6}$/',
    $booking-&amp;gt;reference
);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;For example, HL-123456 passes that
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Functinal testing assertion commands
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Successful API response: assertStatus()&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $response-&amp;gt;assertStatus($expectedStatus);

$response = $this-&amp;gt;getJson('/api/trips/15');

$response-&amp;gt;assertStatus(200);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;JSON contains an exact field: assertJsonPath()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $response-&amp;gt;assertJsonPath($path, $expectedValue);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$response = $this-&amp;gt;getJson('/api/trips/15');

$response-&amp;gt;assertJsonPath('data.id', 15);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Invalid booking is rejected: assertUnprocessable()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $response-&amp;gt;assertUnprocessable();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$response = $this-&amp;gt;postJson('/api/bookings', [
    'trip_id' =&amp;gt; 15,
    'guests' =&amp;gt; 0,
]);

$response-&amp;gt;assertUnprocessable();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Validation identifies a field: assertJsonValidationErrors()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $response-&amp;gt;assertJsonValidationErrors($fields);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$response = $this-&amp;gt;postJson('/api/bookings', [
    'trip_id' =&amp;gt; 15,
    'guests' =&amp;gt; 0,
]);

$response-&amp;gt;assertJsonValidationErrors(['guests']);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Booking exists in the database: assertDatabaseHas()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertDatabaseHas($table, $matchingColumns);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;postJson('/api/bookings', [
    'trip_id' =&amp;gt; 15,
    'guests' =&amp;gt; 2,
]);

$this-&amp;gt;assertDatabaseHas('bookings', [
    'trip_id' =&amp;gt; 15,
    'guests' =&amp;gt; 2,
]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use a dedicated test database for this example.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Invalid booking was not saved: assertDatabaseMissing()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertDatabaseMissing($table, $matchingColumns);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;postJson('/api/bookings', [
    'trip_id' =&amp;gt; 15,
    'guests' =&amp;gt; 0,
]);

$this-&amp;gt;assertDatabaseMissing('bookings', [
    'trip_id' =&amp;gt; 15,
    'guests' =&amp;gt; 0,
]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Guest is sent to login: assertRedirect()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $response-&amp;gt;assertRedirect($expectedUrl);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
$response = $this-&amp;gt;get('/bookings/create?trip_id=15');

$response-&amp;gt;assertRedirect('/login');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  UI testing assertion commands
&lt;/h2&gt;

&lt;p&gt;hese examples run inside a Dusk browser test, typically in a callback such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;browse(function (Browser $browser) {
    // UI checks go here.
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Text appears on a page: assertSee()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $browser-&amp;gt;assertSee($text);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$browser-&amp;gt;visit('/trips/royal-family-getaway')
        -&amp;gt;assertSee('Royal Family Luxury Getaway');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Text does not appear: assertDontSee()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $browser-&amp;gt;assertDontSee($text);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$browser-&amp;gt;visit('/trips/royal-family-getaway/reviews')
        -&amp;gt;assertDontSee('Reviews for Desert Safari');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Button is visible: assertVisible()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $browser-&amp;gt;assertVisible($selector);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
$browser-&amp;gt;visit('/trips/royal-family-getaway')
        -&amp;gt;assertVisible('@view-reviews');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here @view-reviews is a Dusk selector you add to the button.&lt;/p&gt;

&lt;p&gt;11.** Click leads to the right page: assertPathIs()**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $browser-&amp;gt;assertPathIs($expectedPath);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$browser-&amp;gt;visit('/trips/royal-family-getaway')
        -&amp;gt;click('@view-reviews')
        -&amp;gt;assertPathIs('/trips/royal-family-getaway/reviews');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Form contains the expected value: assertInputValue()
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $browser-&amp;gt;assertInputValue($field, $expectedValue);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$browser-&amp;gt;visit('/bookings/create?trip_id=15')
        -&amp;gt;assertInputValue('guests', '1');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Browser input values are strings, hence '1'.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Booking button is disabled: assertDisabled()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $browser-&amp;gt;assertDisabled($selector);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$browser-&amp;gt;visit('/bookings/create?trip_id=15')
        -&amp;gt;assertDisabled('@submit-booking');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, this could check an unavailable trip date.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Validation error appears after a click: assertSee()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $browser-&amp;gt;assertSee($expectedMessage);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$browser-&amp;gt;visit('/bookings/create?trip_id=15')
        -&amp;gt;type('guests', '0')
        -&amp;gt;click('@submit-booking')
        -&amp;gt;assertSee('The guests field must be at least 1.');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Performance testing assertion commands
&lt;/h2&gt;

&lt;p&gt;For these examples, $elapsedMs means a measured duration in milliseconds. Choose the limit from your own environment and requirements; the numbers below are illustrations. Very tight timing assertions can fail when a test server is busy.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Calculation completes under a limit: assertLessThan()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertLessThan($maximum, $actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$start = hrtime(true);
$price = $calculator-&amp;gt;totalForGuests(4500, 4);
$elapsedMs = (hrtime(true) - $start) / 1_000_000;

$this-&amp;gt;assertSame(18000, $price);
$this-&amp;gt;assertLessThan(50, $elapsedMs);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Search duration stays within a limit: assertLessThanOrEqual()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertLessThanOrEqual($maximum, $actual);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$start = hrtime(true);
$results = $searchService-&amp;gt;search('Nainital');
$elapsedMs = (hrtime(true) - $start) / 1_000_000;

$this-&amp;gt;assertNotEmpty($results);
$this-&amp;gt;assertLessThanOrEqual(200, $elapsedMs);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Query count stays within a limit: assertLessThanOrEqual()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertLessThanOrEqual($maximumQueries, $actualQueries);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB::enableQueryLog();

$response = $this-&amp;gt;get('/trips/royal-family-getaway');
$queryCount = count(DB::getQueryLog());

$response-&amp;gt;assertOk();
$this-&amp;gt;assertLessThanOrEqual(20, $queryCount);

DB::disableQueryLog();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run this against a test database. Query count checks can reveal problems such as repeatedly loading reviews one at a time.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Results are paginated: assertCount()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertCount($expectedCount, $collection);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$reviews = $reviewService-&amp;gt;forTrip(tripId: 15, limit: 10);

$this-&amp;gt;assertCount(10, $reviews);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This checks that the service does not return more reviews than requested; it does not measure speed.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Memory growth stays within a limit: assertLessThan()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertLessThan($maximumBytes, $actualBytes);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$before = memory_get_usage(true);
$reviews = $reviewService-&amp;gt;forTrip(tripId: 15, limit: 10);
$growth = memory_get_usage(true) - $before;

$this-&amp;gt;assertLessThan(10 * 1024 * 1024, $growth);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PHP allocates memory in chunks, so use a sensible limit and repeat measurements before relying on this check.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Response has a maximum payload size: assertLessThan()&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: $this-&amp;gt;assertLessThan($maximumBytes, $actualBytes);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$response = $this-&amp;gt;getJson('/api/trips/15/reviews?limit=10');

$response-&amp;gt;assertOk();
$this-&amp;gt;assertLessThan(
    100 * 1024,
    strlen($response-&amp;gt;getContent())
);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This checks that the reviews API does not return an unexpectedly large body.&lt;/p&gt;

&lt;p&gt;Key distinction: Tests 15–17 measure execution or queries; tests 18–20 check factors that can affect performance. For reliable real traffic performance numbers, use a load test alongside these PHPUnit checks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commands to run them
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /opt/lampp/htdocs/holiday-new/booking
php vendor/bin/phpunit --testdox tests/Feature
php artisan dusk
php vendor/bin/phpunit --testsuite Performance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Unit Testing vs Functional Testing vs UI Testing: What Is the Difference</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Mon, 21 Sep 2026 05:52:07 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/unit-testing-vs-functional-testing-vs-ui-testing-what-is-the-difference-487k</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/unit-testing-vs-functional-testing-vs-ui-testing-what-is-the-difference-487k</guid>
      <description>&lt;p&gt;&lt;strong&gt;Testing type and difference&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Command to test&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Testing type and difference
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Unit Testing&lt;/strong&gt;&lt;br&gt;
Unit testing checks one small part of the system&lt;br&gt;
Example: Checking whether HolidayLandmark calculates the correct booking price for three travellers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functional testing&lt;/strong&gt;&lt;br&gt;
Functional testing checks whether a complete feature works correctly.&lt;br&gt;
Example: Checking whether a customer can select a trip, enter traveller details and successfully create a booking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;UI testing&lt;/strong&gt;&lt;br&gt;
UI testing checks what the user sees and uses on the website.&lt;br&gt;
Example: Checking whether the Book Now button is visible, clickable and shows a success message after booking.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/427atms7n592n7dtbxyc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/427atms7n592n7dtbxyc.png" alt=" " width="1080" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/rfbh0ug3vjh2irpc5b07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/rfbh0ug3vjh2irpc5b07.png" alt=" " width="1017" height="372"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Unit Testing
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def calculate_total(price_per_person, travellers):
    return price_per_person * travellers

def test_calculate_total():
    assert calculate_total(5000, 3) == 15000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;It does not check the database, API or booking page—only this function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# tests/test_units.py
import pytest
from datetime import date


# 1. Calculate booking price
def calculate_total(price, travellers):
    return price * travellers

def test_calculate_total():
    assert calculate_total(5000, 3) == 15000


# 2. Apply discount
def apply_discount(total, percentage):
    return total - (total * percentage / 100)

def test_apply_discount():
    assert apply_discount(10000, 10) == 9000


# 3. Calculate tax
def calculate_tax(amount, tax_rate):
    return amount * tax_rate / 100

def test_calculate_tax():
    assert calculate_tax(10000, 18) == 1800


# 4. Validate number of travellers
def validate_travellers(travellers):
    return 1 &amp;lt;= travellers &amp;lt;= 20

def test_validate_travellers():
    assert validate_travellers(4) is True
    assert validate_travellers(0) is False


# 5. Check trip availability
def is_trip_available(available_seats, requested_seats):
    return available_seats &amp;gt;= requested_seats

def test_trip_availability():
    assert is_trip_available(10, 4) is True
    assert is_trip_available(2, 4) is False


# 6. Validate travel dates
def valid_dates(start_date, end_date):
    return end_date &amp;gt;= start_date

def test_valid_dates():
    assert valid_dates(date(2026, 10, 10), date(2026, 10, 15)) is True


# 7. Create booking reference
def create_booking_reference(booking_id):
    return f"HL-{booking_id:06d}"

def test_booking_reference():
    assert create_booking_reference(25) == "HL-000025"


# 8. Calculate average trip rating
def average_rating(ratings):
    return round(sum(ratings) / len(ratings), 1) if ratings else 0

def test_average_rating():
    assert average_rating([4, 5, 5, 4]) == 4.5


# 9. Validate rating range
def valid_rating(rating):
    return 1 &amp;lt;= rating &amp;lt;= 5

def test_valid_rating():
    assert valid_rating(5) is True
    assert valid_rating(6) is False


# 10. Calculate cancellation refund
def calculate_refund(amount, cancellation_charge):
    return amount - cancellation_charge

def test_calculate_refund():
    assert calculate_refund(15000, 2000) == 13000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Functional testing
&lt;/h2&gt;

&lt;p&gt;Functional testing checks whether the complete booking feature works according to the requirement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def test_create_booking(client):
    response = client.post("/bookings", json={
        "trip_id": 10,
        "travellers": 3
    })

    assert response.status_code == 201
    assert response.json()["total_price"] == 15000
    assert response.json()["status"] == "pending"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This test checks that the API creates a booking, calculates the price and returns the correct result.&lt;/p&gt;

&lt;h1&gt;
  
  
  tests/test_functional.py
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Assume &lt;code&gt;client&lt;/code&gt; is a configured FastAPI TestClient.
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
# 1. Create a trip
def test_create_trip(client):
    response = client.post("/trips", json={
        "name": "Goa Beach Holiday",
        "price": 5000,
        "available_seats": 20
    })

    assert response.status_code == 201
    assert response.json()["name"] == "Goa Beach Holiday"


# 2. Get trip details
def test_get_trip(client, created_trip):
    response = client.get(f"/trips/{created_trip['id']}")

    assert response.status_code == 200
    assert response.json()["id"] == created_trip["id"]


# 3. List all trips
def test_list_trips(client):
    response = client.get("/trips")

    assert response.status_code == 200
    assert isinstance(response.json(), list)


# 4. Filter trips by destination
def test_filter_trips(client):
    response = client.get("/trips?destination=Goa")

    assert response.status_code == 200
    assert all(trip["destination"] == "Goa" for trip in response.json())


# 5. Create a booking
def test_create_booking(client):
    response = client.post("/bookings", json={
        "trip_id": 10,
        "travellers": 3
    })

    assert response.status_code == 201
    assert response.json()["status"] == "pending"


# 6. Reject booking when seats are unavailable
def test_booking_without_seats(client):
    response = client.post("/bookings", json={
        "trip_id": 10,
        "travellers": 100
    })

    assert response.status_code == 400
    assert response.json()["detail"] == "Not enough seats"


# 7. Cancel a booking
def test_cancel_booking(client, created_booking):
    response = client.patch(
        f"/bookings/{created_booking['id']}/cancel"
    )

    assert response.status_code == 200
    assert response.json()["status"] == "cancelled"


# 8. Submit a trip review
def test_submit_review(client):
    response = client.post("/reviews", json={
        "trip_id": 10,
        "rating": 5,
        "comment": "Excellent experience"
    })

    assert response.status_code == 201
    assert response.json()["rating"] == 5


# 9. Reject an invalid review rating
def test_invalid_review_rating(client):
    response = client.post("/reviews", json={
        "trip_id": 10,
        "rating": 7,
        "comment": "Invalid rating"
    })

    assert response.status_code == 422


# 10. Prevent unauthorized trip creation
def test_unauthorized_trip_creation(client):
    response = client.post("/trips", json={
        "name": "Kerala Holiday",
        "price": 7000
    })

    assert response.status_code in [401, 403]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  UI testing
&lt;/h2&gt;

&lt;p&gt;UI testing checks the actual HolidayLandmark page that the customer uses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def test_booking_page(page):
    page.goto("https://holidaylandmark.com/trips/10")

    page.fill("#travellers", "3")
    page.click("#book-now")

    assert page.locator(".total-price").inner_text() == "₹15,000"
    assert page.locator(".success-message").is_visible()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  tests/test_ui.py
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BASE_URL = "https://holidaylandmark.com"


# 1. Check homepage heading
def test_homepage_heading(page):
    page.goto(BASE_URL)

    heading = page.locator("h1")
    assert heading.is_visible()


# 2. Search for a destination
def test_search_destination(page):
    page.goto(BASE_URL)

    page.fill("#destination", "Goa")
    page.click("#search-button")

    assert "Goa" in page.locator(".trip-card").first.inner_text()


# 3. Filter trips by price
def test_price_filter(page):
    page.goto(f"{BASE_URL}/trips")

    page.fill("#maximum-price", "10000")
    page.click("#apply-filter")

    prices = page.locator(".trip-price").all_inner_texts()
    assert all(int(p.replace("₹", "").replace(",", "")) &amp;lt;= 10000 for p in prices)


# 4. Open trip details
def test_open_trip_details(page):
    page.goto(f"{BASE_URL}/trips")

    page.locator(".trip-card").first.click()

    assert page.locator(".trip-details").is_visible()


# 5. Complete the booking form
def test_booking_form(page):
    page.goto(f"{BASE_URL}/trips/10")

    page.fill("#travellers", "3")
    page.click("#book-now")

    assert page.locator(".booking-success").is_visible()


# 6. Show an error for zero travellers
def test_invalid_traveller_count(page):
    page.goto(f"{BASE_URL}/trips/10")

    page.fill("#travellers", "0")
    page.click("#book-now")

    assert page.locator(".traveller-error").is_visible()


# 7. User login
def test_user_login(page):
    page.goto(f"{BASE_URL}/login")

    page.fill("#email", "customer@example.com")
    page.fill("#password", "TestPassword123")
    page.click("#login-button")

    assert page.locator(".dashboard").is_visible()


# 8. Add a trip to favourites
def test_add_trip_to_favourites(page):
    page.goto(f"{BASE_URL}/trips/10")

    page.click("#favourite-button")

    assert page.locator("#favourite-button").get_attribute(
        "data-selected"
    ) == "true"


# 9. Submit a review
def test_submit_review_ui(page):
    page.goto(f"{BASE_URL}/bookings/25")

    page.click('[data-rating="5"]')
    page.fill("#review-comment", "Wonderful trip!")
    page.click("#submit-review")

    assert page.locator(".review-success").is_visible()


# 10. Check the mobile menu
def test_mobile_navigation(page):
    page.set_viewport_size({"width": 375, "height": 812})
    page.goto(BASE_URL)

    page.click("#mobile-menu-button")

    assert page.locator("#mobile-menu").is_visible()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Command to test
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /opt/lampp/htdocs/holiday-new/booking
php vendor/bin/phpunit tests/Unit/BookingTransitionsTest.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /opt/lampp/htdocs/holiday-new/booking

php vendor/bin/phpunit --testsuite Unit          # 20 tests, ~60 ms
php vendor/bin/phpunit --testsuite Performance   # 15 tests, no DB — should also pass
php vendor/bin/phpunit --testdox tests/Unit/BookingTransitionsTest.php
php vendor/bin/phpunit --debug   tests/Unit/BookingTransitionsTest.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Mostly used commands&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;unit test&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php vendor/bin/phpunit --testdox tests/Unit/BookingTransitionsTest.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;functional test&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
php vendor/bin/phpunit --testdox tests/Feature/BookingTest.php

php vendor/bin/phpunit --testdox tests/Functional/BookingLifecycleEndpointTest.php

php vendor/bin/phpunit --testsuite Functional --testdox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;UI test&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx playwright test --reporter=list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;performance&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php vendor/bin/phpunit --testsuite Performance --testdox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What command to test when
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/67pid1oj52ak2l1a8ivo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/67pid1oj52ak2l1a8ivo.png" alt=" " width="986" height="295"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /opt/lampp/htdocs/holiday-new/booking
php vendor/bin/phpunit --testdox tests/Unit/BookingTransitionsTest.php

php vendor/bin/phpunit --testdox tests/Unit/AvailabilityRulesTest.php

php vendor/bin/phpunit --debug tests/Unit/BookingTransitionsTest.php


php vendor/bin/phpunit --log-junit test-results.xml tests/Unit/BookingTransitionsTest.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How to Safely Clean Up Server Disk Space Without Deleting Important Data</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Sat, 19 Sep 2026 05:01:07 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/how-to-safely-clean-up-server-disk-space-without-deleting-important-data-5fk7</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/how-to-safely-clean-up-server-disk-space-without-deleting-important-data-5fk7</guid>
      <description>&lt;p&gt;&lt;strong&gt;Inspect Apache logs&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Find Laravel session directories&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Inspect MySQL logs&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Locate backups and installer archives&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Check recovered space&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.debug.school/rakeshdevcotocus_468/how-to-fix-a-cron-email-flood-51mc"&gt;How to Fix a Cron Email Flood&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.debug.school/rakeshdevcotocus_468/how-to-add-swap-space-on-a-linux-server-2o8d"&gt;How to Add Swap Space on a Linux Server&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df -kh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/3toa4sspt34v8sgg0slx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/3toa4sspt34v8sgg0slx.png" alt=" " width="532" height="255"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/dev/sda1  387G  365G  22G  95%  /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;That means the root filesystem / is 95% full.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commands such as df show usage by filesystem, while du helps identify which directories and files consume that space. About df, about du&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Holidaylandmark&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/kgyjlrg1fbn451sxfajz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/kgyjlrg1fbn451sxfajz.png" alt=" " width="587" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/9wfqdjjtwvwxadu7pw85.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/9wfqdjjtwvwxadu7pw85.png" alt=" " width="1097" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/cmvgl5xg5xk14xusqr1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/cmvgl5xg5xk14xusqr1s.png" alt=" " width="1000" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where is /opt/lampp/htdocs stored?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Normally&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/opt/lampp/htdocs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is nested like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/
└── opt
    └── lampp
        └── htdocs
            ├── project-1
            ├── project-2
            └── project-3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because /opt does not appear as a separate mounted filesystem in your df -kh output, it is stored inside:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/dev/sda1 mounted on /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yes, /dev/sda1 is your main filesystem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Size: 387 GB
Used: 365 GB
Available: 22 GB
Usage: 95%
Mounted at: /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because it is mounted on /, begin searching from /.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Find the largest main folders&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This command is safe and does not delete anything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo du -xhd1 / 2&amp;gt;/dev/null | sort -hr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  FASTER SEARCH COMMAND
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo du -sh /opt /var /home /usr /root 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;output&lt;/code&gt;&lt;br&gt;
&lt;a href="https://www.debug.school/uploads/articles/9d9d0vaq5q4ac73w7e93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/9d9d0vaq5q4ac73w7e93.png" alt=" " width="925" height="117"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;next step&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo du -xhd1 /opt 2&amp;gt;/dev/null | sort -hr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;output&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/khafez8w8hpn3t1gcrdy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/khafez8w8hpn3t1gcrdy.png" alt=" " width="820" height="127"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;next step&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo du -xhd1 /opt/lampp 2&amp;gt;/dev/null | sort -hr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;output&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/c2i3z3n3x7ibjrqnbgcv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/c2i3z3n3x7ibjrqnbgcv.png" alt=" " width="902" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;next step&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
sudo du -xhd1 /opt/lampp/htdocs 2&amp;gt;/dev/null |
sort -hr |
head -30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;output&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/meb0gelrunelpv11oinl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/meb0gelrunelpv11oinl.png" alt=" " width="860" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/ohh7vndcf04cygnavskq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/ohh7vndcf04cygnavskq.png" alt=" " width="601" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;next step&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
sudo du -xhd1 /opt/lampp/htdocs/holidaylandmark 2&amp;gt;/dev/null |
sort -hr |
head -30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;output&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/w18eihepsy7cl60ywnbo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/w18eihepsy7cl60ywnbo.png" alt=" " width="866" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may get output like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;365G    /
220G    /opt
90G     /var
40G     /home
8G      /usr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The largest folder is where you search next.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Automatically show the 30 largest folders&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo du -xhd2 / 2&amp;gt;/dev/null | sort -hr | head -30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This checks two directory levels, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;220G    /opt/lampp
180G    /opt/lampp/htdocs
90G     /var/lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For deeper inspection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo du -xhd3 / 2&amp;gt;/dev/null | sort -hr | head -50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This may take some time but is read-only.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check your important server locations separately
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo du -xhd1 /opt 2&amp;gt;/dev/null | sort -hr
sudo du -xhd1 /opt/lampp 2&amp;gt;/dev/null | sort -hr
sudo du -xhd1 /opt/lampp/htdocs 2&amp;gt;/dev/null | sort -hr | head -30
sudo du -xhd1 /var 2&amp;gt;/dev/null | sort -hr | head -30
sudo du -xhd1 /home 2&amp;gt;/dev/null | sort -hr | head -30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Find the 50 largest individual files&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This command searches only /dev/sda1 and does not cross into tmpfs, /boot or other mounted filesystems:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
sudo find / -xdev -type f -printf '%s\t%p\n' 2&amp;gt;/dev/null |
sort -nr |
head -50 |
numfmt --field=1 --to=iec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;82G  /opt/lampp/logs/error_log
19G  /opt/lampp/htdocs/project/storage/framework/sessions/...
10G  /backup/old-backup.tar.gz
3G   /opt/lampp/var/mysql/mysql-slow.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Find all files larger than 1 GB&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find / -xdev -type f -size +1G \
-printf '%s\t%p\n' 2&amp;gt;/dev/null |
sort -nr |
numfmt --field=1 --to=iec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Check if deleted files are still consuming space&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If folder totals do not add up to approximately 365G, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo lsof +L1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For only large deleted-but-open files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
sudo lsof +L1 2&amp;gt;/dev/null |
awk '$7 ~ /^[0-9]+$/ &amp;amp;&amp;amp; $7 &amp;gt; 1073741824 {
    printf "%.2f GB\tPID=%s\tPROCESS=%s\t%s\n",
    $7/1073741824, $2, $1, $9
}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Such files continue using disk space until their owning service closes them or is safely restarted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best single command&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To immediately see the largest folders and files under /dev/sda1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo du -xah / 2&amp;gt;/dev/null | sort -hr | head -50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inspect Apache logs&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo du -ah /opt/lampp/logs 2&amp;gt;/dev/null | sort -h | tail -30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If these are confirmed Apache log files, truncate them without deleting the files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo truncate -s 0 /opt/lampp/logs/access_log
sudo truncate -s 0 /opt/lampp/logs/error_log
sudo truncate -s 0 /opt/lampp/logs/ssl_request_log 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove only already-rotated logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find /opt/lampp/logs -maxdepth 1 -type f \
\( -name "*.gz" -o -name "*.[0-9]" -o -name "*.old" \) \
-print
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After checking the displayed files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find /opt/lampp/logs -maxdepth 1 -type f \
\( -name "*.gz" -o -name "*.[0-9]" -o -name "*.old" \) \
-delete
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Find Laravel session directories&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First list their sizes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find /home /opt/lampp/htdocs -type d \
-path "*/storage/framework/sessions" \
-exec du -sh {} \; 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Preview session files older than seven days:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find /home /opt/lampp/htdocs -type f \
-path "*/storage/framework/sessions/*" \
-mtime +7 -print 2&amp;gt;/dev/null | head -100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete only Laravel file-based sessions older than seven days:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find /home /opt/lampp/htdocs -type f \
-path "*/storage/framework/sessions/*" \
-mtime +7 -delete 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This logs out users whose sessions are older than seven days. If Laravel sessions are stored in a database, this command will not clean them.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inspect MySQL logs&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find /opt/lampp/var/mysql -maxdepth 1 -type f \
\( -name "*.err" -o -name "*slow*.log" -o -name "mysql-bin.*" \) \
-exec ls -lh {} \; 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Truncate only active error and slow-query logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find /opt/lampp/var/mysql -maxdepth 1 -type f \
\( -name "*.err" -o -name "*slow*.log" \) \
-exec truncate -s 0 {} \;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not manually delete mysql-bin.* files. Purge old binary logs through MySQL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo /opt/lampp/bin/mysql -u root -p \
-e "PURGE BINARY LOGS BEFORE (NOW() - INTERVAL 7 DAY);"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Locate backups and installer archives&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Preview likely backup and archive files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo find /home /opt /var/backups -xdev -type f \
\( -name "*.sql" -o -name "*.sql.gz" -o -name "*.tar" \
-o -name "*.tar.gz" -o -name "*.zip" \) \
-size +100M -printf '%10s bytes  %TY-%Tm-%Td  %p\n' 2&amp;gt;/dev/null |
sort -nr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not delete these automatically. Some may be your only valid backups. Delete files only after identifying the exact obsolete paths:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo rm -- "/exact/path/to/confirmed-old-backup.tar.gz"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check recovered space&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df -h /
sudo du -sh /opt/lampp/logs /opt/lampp/var/mysql 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Apache and MySQL log commands preserve active files. For the claimed 10 GB backups and 0.4 GB installers, first use the preview command and delete only explicitly confirmed files.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why FastAPI Uses Pydantic: A Complete Guide to Request Validation with Real-World Examples</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Thu, 10 Sep 2026 05:33:32 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/why-fastapi-uses-pydantic-a-complete-guide-to-request-validation-with-real-world-examples-kpj</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/why-fastapi-uses-pydantic-a-complete-guide-to-request-validation-with-real-world-examples-kpj</guid>
      <description>&lt;p&gt;&lt;strong&gt;Defination&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Why use Pydantic&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Simple example&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Different Pydantic validations&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Complete FastAPI example&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Defination
&lt;/h2&gt;

&lt;p&gt;Pydantic is used in FastAPI to validate, convert and document incoming and outgoing data.&lt;/p&gt;

&lt;p&gt;You define the expected data using a Python class. FastAPI then uses Pydantic automatically to check every request.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why use Pydantic
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://pydantic.dev/docs/validation/latest/get-started/" rel="noopener noreferrer"&gt;Pydantic validation&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Powered by type hints&lt;/strong&gt; — with Pydantic, schema validation and serialization are controlled by type annotations; less to learn, less code to write, and integration with your IDE and static analysis tools. Learn more…&lt;br&gt;
&lt;strong&gt;Speed&lt;/strong&gt;— Pydantic’s core validation logic is written in Rust. As a result, Pydantic is among the fastest data validation libraries for Python. Learn more…&lt;br&gt;
&lt;strong&gt;JSON Schema&lt;/strong&gt; — Pydantic models can emit JSON Schema, allowing for easy integration with other tools. Learn more…&lt;br&gt;
&lt;strong&gt;Strict and Lax mode&lt;/strong&gt;— Pydantic can run in either strict mode (where data is not converted) or lax mode where Pydantic tries to coerce data to the correct type where appropriate. Learn more…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataclasses, TypedDicts and more&lt;/strong&gt; — Pydantic supports validation of many standard library types including dataclass and TypedDict. Learn more…&lt;br&gt;
&lt;strong&gt;Customisation&lt;/strong&gt; — Pydantic allows custom validators and serializers to alter how data is processed in many powerful ways. Learn more…&lt;br&gt;
&lt;strong&gt;Ecosystem&lt;/strong&gt; — around 8,000 packages on PyPI use Pydantic, including massively popular libraries like FastAPI, huggingface, Django Ninja, SQLModel, &amp;amp; LangChain. Learn more…&lt;br&gt;
&lt;strong&gt;Battle tested&lt;/strong&gt; — Pydantic is downloaded over 550M times/month and is used by all FAANG companies and 20 of the 25 largest companies on NASDAQ. If you’re trying to do something with Pydantic, someone else has probably already done it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Simple example
&lt;/h2&gt;

&lt;p&gt;Suppose your API receives a product order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class Order(BaseModel):
    product_name: str
    quantity: int
    price: float
    is_available: bool = True


@app.post("/orders")
def create_order(order: Order):
    return {
        "message": "Order created successfully",
        "order": order
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Valid request:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "product_name": "Laptop",
  "quantity": 2,
  "price": 55000,
  "is_available": true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Invalid request:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "product_name": "Laptop",
  "quantity": "two",
  "price": "expensive"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;FastAPI automatically returns a structured 422 Unprocessable Entity validation response.&lt;/p&gt;

&lt;p&gt;Why Pydantic is important in FastAPI&lt;br&gt;
Validates incoming request data.&lt;br&gt;
Converts compatible values into correct Python types.&lt;br&gt;
Produces understandable validation errors.&lt;br&gt;
Generates the OpenAPI and Swagger documentation.&lt;br&gt;
Validates and filters API responses.&lt;br&gt;
Supports nested and complex data structures.&lt;br&gt;
Reduces repetitive manual if conditions.&lt;br&gt;
Improves type hints and editor autocomplete.&lt;/p&gt;
&lt;h2&gt;
  
  
  Different Pydantic validations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data-type validation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel


class User(BaseModel):
    name: str
    age: int
    salary: float
    active: bool
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Pydantic verifies that every field contains an appropriate value.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Required and optional fields&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel


class User(BaseModel):
    name: str
    email: str
    phone: str | None = None

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;name and email are required, while phone is optional.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Default-value validation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel


class Product(BaseModel):
    name: str
    price: float
    available: bool = True
    currency: str = "INR"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;When the client omits available or currency, Pydantic applies the defaults.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Minimum and maximum numbers&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use Field() for numeric restrictions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, Field


class Product(BaseModel):
    name: str
    price: float = Field(gt=0)
    quantity: int = Field(ge=1, le=100)
    discount: float = Field(ge=0, le=50)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Meaning&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;Constraint  Meaning&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gt=0    Greater than 0
ge=1    Greater than or equal to 1
lt=100  Less than 100
le=100  Less than or equal to 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Minimum and maximum string length&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, Field


class User(BaseModel):
    username: str = Field(min_length=3, max_length=20)
    password: str = Field(min_length=8, max_length=100)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prevents usernames or passwords that are too short or long.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pattern validation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, Field


class User(BaseModel):
    username: str = Field(pattern=r"^[a-zA-Z0-9_]+$")
    country_code: str = Field(pattern=r"^[A-Z]{2}$")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "username": "ashwani_123",
  "country_code": "IN"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spaces and special characters are rejected from username.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Email validation&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Install the email-validation dependency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install "pydantic[email]"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then use EmailStr:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, EmailStr


class User(BaseModel):
    name: str
    email: EmailStr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Valid&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "Ashwani",
  "email": "ashwani@example.com"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Invalid&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "Ashwani",
  "email": "ashwani-example"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;URL validation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, HttpUrl


class Website(BaseModel):
    name: str
    url: HttpUrl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Example&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "HolidayLandmark",
  "url": "https://www.holidaylandmark.com"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Date and time validation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from datetime import date, datetime
from pydantic import BaseModel


class Trip(BaseModel):
    title: str
    travel_date: date
    booking_time: datetime

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Example&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "title": "Manali Adventure",
  "travel_date": "2026-12-15",
  "booking_time": "2026-09-10T10:30:00"
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pydantic converts these strings into Python date and datetime objects.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;List validation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, Field


class Trip(BaseModel):
    title: str
    destinations: list[str] = Field(min_length=1, max_length=10)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At least one destination must be submitted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "title": "Golden Triangle",
  "destinations": ["Delhi", "Agra", "Jaipur"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Enum validation&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use an enum when only predefined values are allowed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from enum import Enum
from pydantic import BaseModel


class BookingStatus(str, Enum):
    pending = "pending"
    confirmed = "confirmed"
    cancelled = "cancelled"


class Booking(BaseModel):
    customer_name: str
    status: BookingStatus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The API accepts only pending, confirmed or cancelled.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Nested-object validation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, EmailStr


class Customer(BaseModel):
    name: str
    email: EmailStr


class Booking(BaseModel):
    trip_id: int
    travellers: int
    customer: Customer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Request&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "trip_id": 501,
  "travellers": 2,
  "customer": {
    "name": "Ashwani",
    "email": "ashwani@example.com"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pydantic validates both the booking and its nested customer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Custom field validation&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use field_validator for custom rules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, field_validator


class User(BaseModel):
    username: str
    password: str

    @field_validator("username")
    @classmethod
    def username_must_be_lowercase(cls, value: str) -&amp;gt; str:
        if value != value.lower():
            raise ValueError("Username must contain lowercase letters only")

        return value

    @field_validator("password")
    @classmethod
    def validate_password(cls, value: str) -&amp;gt; str:
        if not any(character.isdigit() for character in value):
            raise ValueError("Password must contain at least one number")

        return value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Cross-field validation&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use model_validator when one field depends on another:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from datetime import date
from pydantic import BaseModel, model_validator


class Trip(BaseModel):
    start_date: date
    end_date: date

    @model_validator(mode="after")
    def validate_dates(self):
        if self.end_date &amp;lt; self.start_date:
            raise ValueError("End date cannot be before start date")

        return self
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This validation needs both fields, so model_validator is more appropriate than field_validator.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Decimal and currency validation&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For money, prefer Decimal instead of float:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from decimal import Decimal
from pydantic import BaseModel, Field


class Payment(BaseModel):
    amount: Decimal = Field(gt=0, decimal_places=2)
    currency: str = Field(pattern=r"^[A-Z]{3}$")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "amount": "1499.50",
  "currency": "INR"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;UUID validation&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from uuid import UUID
from pydantic import BaseModel


class BookingRequest(BaseModel):
    booking_id: UUID

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Invalid UUID formats are rejected automatically.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Strict validation&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By default, Pydantic may convert compatible data. Strict mode prevents unwanted conversion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, ConfigDict


class QuantityRequest(BaseModel):
    model_config = ConfigDict(strict=True)

    quantity: int
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With strict mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "quantity": "5"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is rejected because "5" is a string rather than an integer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Preventing unexpected fields&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel, ConfigDict


class LoginRequest(BaseModel):
    model_config = ConfigDict(extra="forbid")

    email: str
    password: str
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the client sends an unexpected field, it is rejected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "email": "user@example.com",
  "password": "secret123",
  "is_admin": true
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is especially valuable for security-sensitive APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Complete FastAPI example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from datetime import date
from decimal import Decimal
from enum import Enum

from fastapi import FastAPI
from pydantic import (
    BaseModel,
    ConfigDict,
    EmailStr,
    Field,
    HttpUrl,
    field_validator,
    model_validator,
)

app = FastAPI()


class TripType(str, Enum):
    adventure = "adventure"
    cultural = "cultural"
    leisure = "leisure"


class Customer(BaseModel):
    model_config = ConfigDict(extra="forbid")

    name: str = Field(min_length=2, max_length=80)
    email: EmailStr
    age: int = Field(ge=18, le=100)


class TripBooking(BaseModel):
    model_config = ConfigDict(extra="forbid")

    trip_name: str = Field(min_length=3, max_length=150)
    trip_type: TripType
    start_date: date
    end_date: date
    travellers: int = Field(ge=1, le=20)
    price: Decimal = Field(gt=0, decimal_places=2)
    website: HttpUrl
    customer: Customer
    coupon_code: str | None = Field(
        default=None,
        pattern=r"^[A-Z0-9]{4,12}$"
    )

    @field_validator("trip_name")
    @classmethod
    def clean_trip_name(cls, value: str) -&amp;gt; str:
        return " ".join(value.split())

    @model_validator(mode="after")
    def validate_trip_dates(self):
        if self.end_date &amp;lt; self.start_date:
            raise ValueError("End date cannot be before start date")

        return self


@app.post("/bookings", response_model=TripBooking)
def create_booking(booking: TripBooking):
    return booking

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In simple terms, FastAPI manages the API request while Pydantic works like a security guard that checks every piece of data before allowing it into your application.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to handle Multiple Requests Concurrently using ASGI</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Wed, 09 Sep 2026 06:51:37 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/how-to-handle-multiple-requests-concurrently-using-asgi-1gg2</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/how-to-handle-multiple-requests-concurrently-using-asgi-1gg2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Main Purposes of ASGI&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;What is a Web Framework?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Simple Web Framework Example&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Types of Web Frameworks&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;WSGI vs ASGI&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Recommended frameworks by requirement&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Recommended learning order&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Main Purposes of ASGI
&lt;/h2&gt;

&lt;p&gt;Use this as your blog heading:&lt;/p&gt;

&lt;p&gt;ASGI Explained: 5 Reasons Modern Python Applications Need It&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Handle Multiple Requests Concurrently&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;ASGI allows the application to process other requests while waiting for databases, APIs or files.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Support Asynchronous Programming&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It provides native support for Python’s async and await, making I/O-heavy applications more efficient.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Enable Real-Time Communication&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;ASGI supports WebSockets for live chat, notifications, order tracking and collaborative applications.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Manage Long-Lived Connections&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It can maintain connections required for streaming, Server-Sent Events, live dashboards and continuous updates.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Improve Scalability and Resource Usage&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;ASGI can manage many concurrent connections without requiring a separate thread or process for every waiting request.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is a Web Framework?
&lt;/h2&gt;

&lt;p&gt;A web framework is a collection of ready-made tools that helps developers build websites, web applications and APIs.&lt;/p&gt;

&lt;p&gt;Without a framework, developers must manually write code for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Receiving HTTP requests
Sending HTTP responses
URL routing
Authentication
Database connections
Input validation
Security
Error handling
Cookies and sessions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A web framework provides these common features, allowing developers to focus on business requirements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simple real-life example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you want to build a house.&lt;/p&gt;

&lt;p&gt;Without a framework, you must manufacture everything yourself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bricks
Doors
Windows
Electrical equipment
Plumbing equipment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a framework, these building materials are already available. You only need to arrange and customize them.&lt;/p&gt;

&lt;p&gt;Similarly, Django, Flask and FastAPI provide the building blocks needed to create web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple Web Framework Example
&lt;/h2&gt;

&lt;p&gt;Without discussing database or authentication, a framework lets you create an endpoint easily:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI

app = FastAPI()

@app.get("/hello")
async def hello():
    return {"message": "Hello, Ashwani"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When someone opens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8000/hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "message": "Hello, Ashwani"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, FastAPI manages the HTTP request, routing and JSON response.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Web Frameworks
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Full-Stack Framework&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A full-stack framework provides almost everything required to build a complete application.&lt;/p&gt;

&lt;p&gt;Common features include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;URL routing
Database ORM
Authentication
Admin panel
Form handling
HTML templates
Sessions and cookies
Security features
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Examples&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Django
Ruby on Rails
Laravel
Spring Boot
Best scenario
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Use a full-stack framework when building:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Admin portals
E-commerce applications
School management systems
Content-management systems
Complete business applications
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;Django provides a model, admin panel and authentication system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.db import models

class Product(models.Model):
    name = models.CharField(max_length=100)
    price = models.DecimalField(
        max_digits=10,
        decimal_places=2
    )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Microframework&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A microframework provides only the basic web-development features.&lt;/p&gt;

&lt;p&gt;Usually, it contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Routing
Request handling
Response handling
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You add database, validation and authentication libraries according to your requirements.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Flask
Bottle
Sinatra
Best scenario
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Use it for:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Small applications
Prototypes
Simple APIs
Projects requiring complete architectural freedom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Flask example&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, jsonify

app = Flask(__name__)

@app.route("/products")
def products():
    return jsonify([
        {"id": 1, "name": "Laptop"},
        {"id": 2, "name": "Phone"}
    ])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;API-First Framework&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An API-first framework is designed mainly for building APIs that return JSON to frontend or mobile applications.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FastAPI
Django REST Framework
NestJS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common features include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request validation
JSON responses
API documentation
Authentication support
Serialization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Best scenario&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Use it for:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;React application backends
Mobile application backends
Microservices
AI applications
Booking and payment APIs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;FastAPI example&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class Product(BaseModel):
    name: str
    price: float

@app.post("/products")
async def create_product(product: Product):
    return {
        "message": "Product created",
        "product": product
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Asynchronous Framework&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An asynchronous framework can serve other requests while waiting for slow I/O operations.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FastAPI
Starlette
Sanic
Tornado
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is useful when the application frequently waits for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Database queries
External APIs
File operations
AI models
Network services
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI
import asyncio

app = FastAPI()

@app.get("/payment-status")
async def payment_status():
    await asyncio.sleep(2)

    return {"status": "successful"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During the two-second wait, the server can process other requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  WSGI vs ASGI
&lt;/h2&gt;

&lt;p&gt;Full forms&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WSGI: Web Server Gateway Interface
ASGI: Asynchronous Server Gateway Interface

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They define how a Python web server communicates with a Python web application.&lt;/p&gt;

&lt;p&gt;User → Web Server → WSGI/ASGI → Python Application&lt;br&gt;
&lt;strong&gt;Tabular difference&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/f2pbrd217q2gwvc6lsze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/f2pbrd217q2gwvc6lsze.png" alt=" " width="977" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/3zhydht9ye71z68faq3q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/3zhydht9ye71z68faq3q.png" alt=" " width="1106" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simple real-world example&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;WSGI: One cashier per counter&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine one customer gives the cashier a task that takes five minutes.&lt;/p&gt;

&lt;p&gt;The cashier waits until the task finishes before handling the next customer.&lt;/p&gt;

&lt;p&gt;To serve more customers, the shop needs more cashiers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ASGI: Restaurant waiter&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A waiter takes your order and sends it to the kitchen.&lt;/p&gt;

&lt;p&gt;While the kitchen prepares your food, the waiter serves other customers. When your food is ready, the waiter returns.&lt;/p&gt;

&lt;p&gt;ASGI works similarly when waiting for:&lt;/p&gt;

&lt;p&gt;Database results&lt;br&gt;
Payment gateways&lt;br&gt;
External APIs&lt;br&gt;
AI-model responses&lt;br&gt;
&lt;strong&gt;WSGI Coding Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flask commonly runs as a WSGI application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask
import time

app = Flask(__name__)

@app.get("/order")
def create_order():
    # Blocking operation
    time.sleep(3)

    return {
        "message": "Order created"
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it with Gunicorn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gunicorn app:app --workers 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When time.sleep(3) executes, that worker remains blocked for three seconds.&lt;/p&gt;

&lt;p&gt;The four-worker configuration allows multiple requests to be processed, but each waiting request occupies a worker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ASGI Coding Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FastAPI runs as an ASGI application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI
import asyncio

app = FastAPI()

@app.get("/order")
async def create_order():
    # Non-blocking waiting operation
    await asyncio.sleep(3)

    return {
        "message": "Order created"
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it with Uvicorn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uvicorn app:app --host 0.0.0.0 --port 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While one request is waiting, the event loop can process other requests.&lt;/p&gt;

&lt;p&gt;Important difference in the code&lt;/p&gt;

&lt;p&gt;WSGI-style blocking code:&lt;/p&gt;

&lt;p&gt;time.sleep(3)&lt;/p&gt;

&lt;p&gt;ASGI-style non-blocking code:&lt;/p&gt;

&lt;p&gt;await asyncio.sleep(3)&lt;/p&gt;

&lt;p&gt;It is not enough to write async def. The database client and external API libraries must also support asynchronous operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Example&lt;/strong&gt;&lt;br&gt;
Synchronous WSGI-style operation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.get("/orders")
def get_orders():
    orders = sync_database.query("SELECT * FROM orders")
    return {"orders": orders}

The worker waits until the database responds.

Asynchronous ASGI-style operation
@app.get("/orders")
async def get_orders():
    orders = await async_database.fetch(
        "SELECT * FROM orders"
    )

    return {"orders": orders}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;FastAPI can handle other requests while the database operation is waiting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/600o5fo5uxbo1vcc3hg9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/600o5fo5uxbo1vcc3hg9.png" alt=" " width="832" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Recommended frameworks by requirement
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/v0v6clt8no4zakfzqbf8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/v0v6clt8no4zakfzqbf8.png" alt=" " width="841" height="592"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Recommended learning order
&lt;/h2&gt;

&lt;p&gt;FastAPI — make this your primary Python&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/2923uupwd8l7h6vhq27w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/2923uupwd8l7h6vhq27w.png" alt=" " width="762" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How FastAPI Handles Requests Efficiently</title>
      <dc:creator>rakesh kumar</dc:creator>
      <pubDate>Wed, 09 Sep 2026 05:50:48 +0000</pubDate>
      <link>https://www.debug.school/rakeshdevcotocus_468/how-fastapi-handles-requests-efficiently-5f5h</link>
      <guid>https://www.debug.school/rakeshdevcotocus_468/how-fastapi-handles-requests-efficiently-5f5h</guid>
      <description>&lt;p&gt;&lt;strong&gt;How FastAPI Handles Requests Efficiently&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Is FastAPI always better?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Is FastAPI a “pure backend” framework?&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How FastAPI Handles Requests Efficiently
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous Request Handling&lt;/strong&gt;&lt;br&gt;
FastAPI can process other requests while waiting for databases or external APIs.&lt;br&gt;
&lt;strong&gt;High-Speed ASGI Architecture&lt;/strong&gt;&lt;br&gt;
It uses ASGI servers such as Uvicorn to handle many concurrent connections efficiently.&lt;br&gt;
&lt;strong&gt;Automatic Data Validation&lt;/strong&gt;&lt;br&gt;
FastAPI validates incoming data early, preventing invalid requests from reaching business logic.&lt;br&gt;
&lt;strong&gt;Background Task Processing&lt;/strong&gt;&lt;br&gt;
Slow tasks such as emails, invoices, and notifications can run in the background.&lt;br&gt;
&lt;strong&gt;Easy Horizontal Scaling&lt;/strong&gt;&lt;br&gt;
Multiple FastAPI instances can run behind a load balancer to distribute heavy traffic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/j4wtsbarijn1gq36kwhq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/j4wtsbarijn1gq36kwhq.png" alt=" " width="1117" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous Request Handling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When FastAPI is waiting for a database or another API, it can process other requests instead of keeping the server blocked.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Coding example&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI
import asyncio

app = FastAPI()

@app.get("/orders/{order_id}")
async def get_order(order_id: int):
    # Imagine this is an asynchronous database request
    await asyncio.sleep(2)

    return {
        "order_id": order_id,
        "status": "confirmed"
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The async and await keywords allow the server to handle another request during the two-second waiting period.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Real-world example&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Think of a restaurant waiter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The waiter takes your order.
The kitchen starts preparing it.
Instead of standing in the kitchen, the waiter serves other customers.
The waiter returns when your food is ready.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;FastAPI works similarly while waiting for databases, payment gateways or external APIs.&lt;/p&gt;

&lt;p&gt;Async improves waiting-based operations. It does not automatically speed up CPU-heavy work such as video processing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;High-Speed ASGI Architecture&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;FastAPI runs on the ASGI standard using servers such as Uvicorn. ASGI is designed to handle asynchronous operations and many concurrent connections.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Coding example&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create main.py:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI

app = FastAPI()

@app.get("/")
async def home():
    return {"message": "FastAPI is running"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Start the application:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uvicorn main:app --host 0.0.0.0 --port 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run multiple worker processes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uvicorn main:app \
  --host 0.0.0.0 \
  --port 8000 \
  --workers 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The workers allow the server to use multiple CPU cores and process more traffic.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Real-world example&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Imagine a bank:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;One counter can serve only one customer at a time.
Four counters can serve four customers simultaneously.
Customers are distributed among available counters.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The four Uvicorn workers act like four service counters.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Automatic Data Validation&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;FastAPI uses Pydantic models to check incoming request data before sending it to the business logic.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Coding example&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI
from pydantic import BaseModel, Field

app = FastAPI()

class OrderRequest(BaseModel):
    product_id: int
    quantity: int = Field(gt=0, le=10)
    customer_email: str

@app.post("/orders")
async def create_order(order: OrderRequest):
    return {
        "message": "Order accepted",
        "order": order
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Valid request&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "product_id": 101,
  "quantity": 2,
  "customer_email": "customer@example.com"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Invalid request&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "product_id": "phone",
  "quantity": -5
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;FastAPI rejects the invalid request automatically. The main order-processing code does not need to handle obviously incorrect values.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Real-world example&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Consider security at an airport:&lt;/p&gt;

&lt;p&gt;Passengers are checked before entering the boarding area.&lt;br&gt;
People without valid documents are stopped at the entrance.&lt;br&gt;
Only validated passengers reach the aircraft.&lt;/p&gt;

&lt;p&gt;Similarly, FastAPI stops invalid data before it reaches the database or business logic.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Background Task Processing&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;FastAPI can return a response without making the user wait for small secondary tasks such as sending a confirmation email.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Coding example&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI, BackgroundTasks

app = FastAPI()

def send_confirmation_email(email: str):
    print(f"Confirmation email sent to {email}")

@app.post("/orders")
async def create_order(
    email: str,
    background_tasks: BackgroundTasks
):
    # Save the order first

    background_tasks.add_task(
        send_confirmation_email,
        email
    )

    return {
        "message": "Order placed successfully"
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The customer receives the order response first. The email task runs afterward.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Real-world example&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When you place an online food order:&lt;/p&gt;

&lt;p&gt;The application immediately shows “Order confirmed.”&lt;br&gt;
The restaurant begins preparing the food.&lt;br&gt;
The notification and invoice are processed separately.&lt;/p&gt;

&lt;p&gt;You do not need to wait for every secondary activity before seeing the confirmation.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Important production point&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;FastAPI BackgroundTasks is suitable for small, non-critical work. For heavy or critical tasks, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Celery
RabbitMQ
Kafka
Redis Queue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Examples include payment processing, video conversion, invoice generation and bulk email delivery.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Easy Horizontal Scaling&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can run multiple FastAPI application instances behind a load balancer. Incoming requests are distributed across those instances.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Coding example&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Assume FastAPI is running on three servers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FastAPI instance 1 → Port 8001
FastAPI instance 2 → Port 8002
FastAPI instance 3 → Port 8003
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An Nginx load-balancer configuration could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;upstream fastapi_servers {
    server 127.0.0.1:8001;
    server 127.0.0.1:8002;
    server 127.0.0.1:8003;
}

server {
    listen 80;

    location / {
        proxy_pass http://fastapi_servers;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nginx distributes incoming requests among the three application instances.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Real-world example&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Imagine a supermarket:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;One billing counter creates a long queue.
The manager opens several more counters.
Customers are distributed among all available counters.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, additional FastAPI instances can be added when traffic increases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/fhgprn1b6fgkrk1cdrs0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/fhgprn1b6fgkrk1cdrs0.png" alt=" " width="1027" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Is FastAPI always better?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.debug.school/uploads/articles/89v4mdy0xxahp3r9vrpi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://www.debug.school/uploads/articles/89v4mdy0xxahp3r9vrpi.png" alt=" " width="941" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Is FastAPI a “pure backend” framework?
&lt;/h2&gt;

&lt;p&gt;FastAPI is often called a pure API/backend framework because it focuses mainly on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Building REST APIs
Receiving requests and returning JSON
Data validation
Authentication and authorization
Connecting frontend/mobile apps with databases and services
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, saying Django and Flask are not backend frameworks is incorrect. All three are backend frameworks, but their focus is different:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FastAPI: API-first backend
Django: Complete web-application framework
Flask: Minimal and flexible backend framework
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
