การปรับขนาดและปรับแต่งประสิทธิภาพใน RDS
เรียนรู้การปรับขนาดอินสแตนซ์ Amazon RDS ทั้งแนวตั้งและแนวนอน การตรวจสอบประสิทธิภาพ และการปรับแต่งฐานข้อมูลสำหรับภาระงานจริง
การปรับขนาดและปรับแต่งประสิทธิภาพใน RDS เป็นบทเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส AWS for Backend Developers (EC2, S3, RDS, Lambda) มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why Scaling Matters
As your application grows, a single RDS instance may struggle to keep up with traffic. Scaling ensures your database stays responsive under load.
There are two broad strategies:
- Vertical scaling — make the instance bigger (more CPU/RAM)
- Horizontal scaling — spread reads across multiple instances
Vertical Scaling (Instance Class)
Vertical scaling means changing the DB instance class, for example moving from db.t3.medium to db.m6g.large.
RDS applies the change during a maintenance window or immediately, usually with a short restart.
aws rds modify-db-instance \
--db-instance-identifier mydb \
--db-instance-class db.m6g.large \
--apply-immediatelyStorage Auto Scaling
RDS can automatically grow your storage when free space runs low. Enable Storage Autoscaling and set a maximum threshold so you never run out of disk unexpectedly.
- Set a max allocated storage cap
- RDS adds storage in increments as needed
aws rds modify-db-instance \
--db-instance-identifier mydb \
--max-allocated-storage 500 \
--apply-immediatelyRead Replicas for Read Scaling
For read-heavy workloads, create read replicas. Replicas serve SELECT queries while the primary handles writes.
Point reporting dashboards and analytics at replicas to take load off the primary.
aws rds create-db-instance-read-replica \
--db-instance-identifier mydb-replica \
--source-db-instance-identifier mydbConnection Pooling with RDS Proxy
Opening too many database connections wastes memory and can exhaust limits. Amazon RDS Proxy pools and reuses connections, which is especially helpful for serverless apps and Lambda.
- Reduces connection overhead
- Improves failover times
Monitoring with Enhanced Monitoring
Enhanced Monitoring gives OS-level metrics (CPU, memory, disk I/O) at up to 1-second granularity. Combine it with CloudWatch to spot bottlenecks before they cause outages.
Performance Insights
Performance Insights visualizes database load and shows you the top SQL statements, waits, and users driving load.
Use it to identify slow queries that need indexing or rewriting.
Indexing for Faster Queries
The single biggest performance win is often a good index. Indexes let the database find rows without scanning the whole table.
Add indexes on columns used in WHERE, JOIN, and ORDER BY clauses.
CREATE INDEX idx_orders_customer
ON orders (customer_id);Parameter Groups for Tuning
RDS exposes engine settings through DB parameter groups. Tune values like max_connections or buffer pool size to match your workload.
Create a custom parameter group rather than editing the default.
aws rds create-db-parameter-group \
--db-parameter-group-name mydb-tuned \
--db-parameter-group-family mysql8.0 \
--description 'Tuned for prod'Caching to Reduce DB Load
Not every query needs to hit the database. Put a cache like Amazon ElastiCache (Redis/Memcached) in front of RDS for frequently read, rarely changing data.
- Lower latency for hot data
- Fewer queries reaching RDS
Scaling Checklist
Before scaling, follow this order:
- Profile with Performance Insights
- Add or fix indexes
- Offload reads to replicas
- Add caching
- Only then scale the instance up
Throwing a bigger instance at a missing index is expensive and rarely the real fix.
Quick Check
Test your scaling knowledge.
Recap
You learned to scale RDS effectively:
- Vertical scaling changes the instance class
- Read replicas scale reads horizontally
- RDS Proxy pools connections
- Performance Insights and indexing tune queries
Always profile first, fix indexes, offload and cache before paying for a bigger instance.
คำถามที่พบบ่อย
บทเรียน “การปรับขนาดและปรับแต่งประสิทธิภาพใน RDS” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การปรับขนาดและปรับแต่งประสิทธิภาพใน RDS” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส AWS for Backend Developers (EC2, S3, RDS, Lambda) ให้อัปเกรดเป็น CoddyKit PRO คอร์ส AWS for Backend Developers (EC2, S3, RDS, Lambda) มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การปรับขนาดและปรับแต่งประสิทธิภาพใน RDS”
เรียนรู้การปรับขนาดอินสแตนซ์ Amazon RDS ทั้งแนวตั้งและแนวนอน การตรวจสอบประสิทธิภาพ และการปรับแต่งฐานข้อมูลสำหรับภาระงานจริง คุณปฏิบัติ AWS for Backend Developers (EC2, S3, RDS, Lambda) ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน AWS for Backend Developers (EC2, S3, RDS, Lambda) บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “การปรับขนาดและปรับแต่งประสิทธิภาพใน RDS” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) นี้ได้ไหม
ได้ บทเรียน AWS for Backend Developers (EC2, S3, RDS, Lambda) ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- บทนำ Amazon RDS
- การเปิดใช้งานและเชื่อมต่อกับ RDS
- การสำรองข้อมูลและความพร้อมใช้งานสูงของ RDS
- การปรับขนาดและปรับแต่งประสิทธิภาพใน RDS