16.1 Why RDS instead of MySQL on EC2
In Chapter 10 the database and the website share one virtual machine. That is one useful learning arrangement. In a real project, plan the database lifetime, storage retention and recovery separately from application releases. EC2 failure does not automatically destroy separately retained EBS data. Amazon RDS (Relational Database Service) runs a relational database for you.
| MySQL or MariaDB on EC2 (Chapters 10–12) | Amazon RDS | |
|---|---|---|
| Who installs and patches the engine | Your team, using supported installation, maintenance and automation procedures | AWS operates supported installation and patching facilities; you review compatibility, maintenance choices and application acceptance. |
| Backups | Your team selects a database-consistent backup method, retention and tested restore process | Configured automated backups, manual snapshots and supported point-in-time recovery into a new destination |
| Capacity, availability and failover | You design it | Managed facilities depend on the chosen deployment and configuration; capacity limits and application failover behavior still need testing |
| SQL, tables, indexes, users | You | You. This does not change |
| Where it runs | On your instance | On AWS-managed hosts, with placement governed by the selected DB subnet group and deployment |
Your continuing responsibilities: schema and queries, database identities and privileges, credential handling, network access, application configuration and recovery acceptance. Standard RDS does not provide ordinary host SSH access to edit my.cnf; supported engine settings use facilities such as a parameter group (section 16.9). RDS Custom is a separate service option for supported SQL Server and Oracle configurations; AWS has announced the end of RDS Custom for Oracle support and access on 31 March 2027.
Ravindra Bagale's Tip
Many students say "I installed MySQL, so the data is on my server." With RDS, the database runs in a separately managed environment; it does not have to be in a different subnet from your application. EC2 runs your application and its database client, using the configured endpoint and authentication method. For MySQL using port 3306, the network path and security groups must permit that port; authentication and SQL permissions are separate checks. Verify each part.
Ravindra Bagale's Tip – मराठी
बरेच students म्हणतात "MySQL install केला, म्हणजे data माझ्या server वर आहे." RDS database स्वतंत्रपणे व्यवस्थापित वातावरणात चालतो; application पेक्षा वेगळ्या subnet मध्येच असणे आवश्यक नाही. EC2 वर application आणि database client चालतात. ते योग्य endpoint आणि authentication पद्धत वापरतात. MySQL साठी port 3306 निवडला असेल तर network path आणि security groups ने तो port परवानगी दिली पाहिजे. Login आणि SQL permissions या वेगळ्या तपासण्या आहेत. प्रत्येक भाग तपासा.
Ravindra Bagale's Tip – हिंदी
बहुत students कहते हैं "MySQL install किया, मतलब data मेरे server पर है." RDS database अलग प्रबंधित वातावरण में चलता है; application से अलग subnet में होना हमेशा जरूरी नहीं है. EC2 पर application और database client चलते हैं. वे सही endpoint और authentication विधि इस्तेमाल करते हैं. MySQL के लिए port 3306 चुना हो तो network path और security groups में उस port की अनुमति चाहिए. Login और SQL permissions अलग जाँच हैं. हर भाग जाँचें.
1. Start with the records your application must keep
A college engineering workshop has a repair-ticket application. A student reports a faulty drilling machine, the technician records the diagnosis, and the workshop supervisor approves the repair. Ticket 101 might move from reported to inspected and then completed over several days. The screen can be redesigned during that time, but the ticket must continue to exist with the correct history. This is the practical reason to think carefully about where the database runs and who operates it.
Initially, a student installs MySQL and a small website on one EC2 instance. This is a useful learning arrangement because the application and database are easy to inspect together. The next question is not whether the student has successfully installed a package. It is whether the workshop can keep using the service through updates, mistakes, growing data and failures. Who prepares a backup? Who notices that storage is nearly full? Who proves that a restored ticket has the right status?
Amazon RDS, the Relational Database Service, provides managed database infrastructure. With standard RDS for MySQL, AWS takes responsibility for operating many of the underlying database-service components. With self-managed MySQL on EC2, your team operates MySQL and the guest operating system using the compute service AWS provides. In both arrangements, your application still needs correct tables, queries, transactions and permissions.
Choosing RDS can reduce the infrastructure work your team performs, but it does not remove the need for database understanding. A mistaken query can update the wrong tickets in either environment. A poorly designed application can exhaust database connections in either environment. The service choice changes the operating arrangement around the engine; it does not change an incorrect business rule into a correct one.
This lesson develops a decision method. We will compare responsibilities, separate application replacement from data recovery, examine the limits of automation and practice checking a candidate database. The examples use fictional repair tickets. The local exercises do not connect to AWS, create a database service or require a payment method.
2. Separate the application, database engine and stored records
The application is the program that receives a request such as “show the open repair tickets.” The database engine is the program that interprets SQL, manages concurrent access and stores committed changes. The stored records are the workshop's information: equipment identifiers, ticket descriptions, status changes and approval records. These parts cooperate, but they have different lifetimes and responsibilities.
Installing a MySQL client on an application machine does not install the database server there. A client is software that sends requests to a database engine. Your application can use a driver library to make the same kind of connection. The engine may run on that machine, on another EC2 instance or in RDS. Follow the configured destination before deciding where the authoritative records are stored.
A database instance is also not the same thing as one table. In standard RDS, a DB instance provides an isolated database environment with selected engine and resource characteristics. It can contain multiple user-created databases, each with its own objects as supported by the engine. A table such as repair_tickets belongs within that logical database arrangement. Deleting a table and deleting the DB instance are very different operations.
Storage must be considered separately from the computer process. A database process can stop while its durable files remain. An EC2 instance can fail without every attached EBS volume necessarily being destroyed. Conversely, a configured deletion action can remove storage you intended to keep. The useful question is which resource owns the records, what its retention settings are and how you would recover useful data after the specific failure.
For our workshop, write one sentence identifying the authority: “The repair database is the authoritative source for ticket status.” A browser display, application log or exported spreadsheet may contain a copy, but that does not automatically make it the current source of truth. This distinction becomes important when comparing a restored copy with newer records still present in the active database.
3. Compare three layouts before comparing service names
| Layout | What is separated? | What the team still operates |
|---|---|---|
| Application and MySQL on one EC2 instance | Different processes share the same guest machine | Application, guest OS, database engine, storage and recovery procedures |
| Application EC2 and separate MySQL EC2 | Application compute and database compute are separate | Both guest environments, database operations and connection design |
| Application EC2 and standard RDS MySQL | Application compute and managed database service are separate | Application behavior, database design, access choices and recovery acceptance |
The second layout matters because separating data from the application is not a feature exclusive to RDS. A team can run a separately managed database on EC2. It then gains a separate operating boundary while keeping responsibility for database-host maintenance and recovery mechanisms. Comparing only “everything on one computer” with “RDS” can hide this valid architectural choice.
Suppose the application needs a new Python version. In the first layout, a careless machine rebuild can affect both the application and database installation. In the other layouts, the application can be replaced while the existing database remains a separate resource. The replacement still needs the correct release, endpoint, credentials and network path. Separate placement helps limit the change; it does not configure the replacement automatically.
Now suppose the database engine itself requires maintenance. All three layouts need a plan for how the application behaves while database access is interrupted or changed. With EC2, your team performs more of the underlying work. With standard RDS, AWS performs the managed operation, while your team still coordinates its application and verifies the result.
Do not confuse this separation with a mandatory different subnet. An RDS instance and an application instance can be associated with subnets in the same VPC, and their exact placement depends on the design. Database subnet groups, routes and security groups need to be understood individually. “Different managed resource” is the essential distinction in this lesson; “always in a different subnet” would be an inaccurate universal rule.
4. Turn managed responsibility into a practical task list
A responsibility table is useful when it names an action and an expected result. “AWS manages the database” is too broad to tell a student who fixes a bad query. “Our team verifies that ticket 101 can be read and updated after maintenance” identifies a concrete responsibility. Think in terms of mechanisms supplied by a service and decisions retained by the application owner.
| Task | Self-managed MySQL on EC2 | Standard RDS MySQL |
|---|---|---|
| Maintain the guest OS and engine installation | The team selects, installs and operates them | AWS operates the managed host and engine lifecycle within service controls |
| Select suitable engine settings and change timing | The team configures and applies its supported changes | The team chooses supported service settings and coordinates changes |
| Protect and restore database data | The team builds and operates the backup and restore arrangement | Managed mechanisms are available; the team configures requirements and verifies recovery |
| Design tables and correct SQL | The team | The team |
| Grant the application appropriate data access | The team | The team |
| Accept a repaired service as usable | The team checks the application result | The team checks the application result |
For ticket creation, a database administrator might create a constrained application account. A developer writes the SQL transaction. An operator configures monitoring and recovery procedures. In a small project one person may do all three jobs, but the responsibilities still exist. Naming them prevents the mistaken assumption that a managed engine is also the person who understands the workshop's approval policy.
A useful ownership note includes a trigger, an owner and evidence. For example: when free storage approaches the agreed threshold, the designated operator reviews growth and capacity; after action, the team confirms both sufficient space and successful ticket updates. Merely assigning a person to receive an email is not a complete procedure if nobody knows what the alert means or which response is appropriate.
With self-managed EC2, the team can automate many operations too. Automation is not exclusive to a managed service. The difference is who builds, maintains and supports that automation. A scheduled backup script needs credentials, error handling, monitoring, retention and restore testing. If its owner leaves the project, the script still needs somebody responsible for those outcomes.
5. Understand the control you gain and the work it creates
Standard RDS does not offer ordinary SSH access to the underlying database host. You manage supported settings through service interfaces, parameter groups and database-level operations. This boundary lets AWS control the environment it is responsible for operating. It also means a procedure that requires editing arbitrary host files or installing an unsupported extension cannot simply be copied from an EC2 tutorial.
Check the exact requirement before rejecting RDS. An application might need a setting that RDS supports through a parameter group. Another might depend on a particular plugin, privilege or operating-system integration that is unavailable in the chosen service configuration. Record the required feature, engine version and supported alternative. “We need full control” is less useful than naming the operation that requires that control.
RDS Custom is a separate option with additional access to supported database environments and their operating systems. As of 23 November 2026, its scope includes SQL Server and Oracle, but AWS has announced that RDS Custom for Oracle support and access will end on 31 March 2027. Do not treat the Oracle option as an ongoing choice beyond that announced date. It has its own responsibility model and support boundaries. It is not a MySQL switch that adds unrestricted host access to ordinary RDS for MySQL. For this lesson's MySQL comparison, investigate the actual standard-RDS requirements and a self-managed design rather than assuming every RDS option supports every engine.
Maintenance is still a change that can affect users. RDS maintenance can involve the host, operating system or engine, and some items can take a database offline. The maintenance window is an operating control, not a guarantee that the application will never notice a change. Your team should understand pending work, compatibility and the application's reconnection behavior.
For example, schedule a rehearsal using a non-production copy of the repair application. Record an open ticket, apply the candidate change in the authorised test environment, reconnect with the application's normal account and perform the agreed read and update operations. Check logs and results before accepting the change. On EC2 the underlying steps differ, but the acceptance question remains: can the workshop continue its required work correctly?
6. Keep network access and database permission separate
The repair application needs several conditions to connect successfully. Its configured hostname must identify the intended database endpoint. Its network path must reach the database port. The database must accept the chosen authentication method. The resulting database identity must have permission to perform the required SQL operation. Treat these as separate checks, because success at one stage does not grant the others.
A security group can permit traffic from the application's security group to the intended database port. It does not create a database user or grant that user permission to change a table. Similarly, an account allowed to modify an RDS resource through AWS APIs does not automatically become an unrestricted SQL administrator inside the database. IAM resource management and database data access need their own configuration.
Authentication methods vary by engine and version. Password authentication is common; supported RDS configurations also offer IAM database authentication and other options. The application should use the intended identity mechanism rather than assume that a password must be pasted into a source file. Secret delivery, rotation and application behavior during a credential change remain operational responsibilities.
For our workshop, the everyday application account might read equipment records and create or update repair tickets. It does not need permission to delete the entire database or manage every user. A separate controlled maintenance identity can perform schema changes when authorised. This separation reduces the consequences of an ordinary application mistake and makes the intended purpose of each account clearer.
Use TLS with the appropriate client verification configuration for the engine. Encryption in transit, encryption of stored data and SQL authorization answer different questions. A connection can be encrypted while the account has excessive data privileges. An encrypted database can still serve a permitted destructive SQL command. Good design considers both how data is protected and which operations the application is allowed to request.
7. Decide how the workshop will recover its records
Suppose a staff member accidentally marks every open repair ticket as completed. The database remains reachable and its storage is healthy. The problem is that the stored information no longer describes the workshop. Restarting a server does not restore the earlier meaning of those records. You need usable recovery history and a procedure for selecting the right information from it.
RDS offers automated backups and manual snapshots according to its documented configuration and engine rules. For a DB instance, automated backups cover the instance rather than one chosen application table. Check that retention is enabled and that the desired recovery interval is actually available. A checkbox in an old setup screenshot is not evidence that today's missing tickets can be recovered.
Point-in-time recovery of an RDS DB instance creates another DB instance. It does not silently rewind the existing source. The new destination gives you somewhere to inspect the earlier records. It also introduces a practical decision: will you recover selected records, or move the application to a fully validated replacement? Those are different operations with different effects on legitimate work completed after the mistake.
For example, ticket 101 may need its earlier status restored while ticket 104, created after the mistake, must be retained. Replacing the entire current database with an older copy could lose ticket 104. A recovery plan should explain how the team will distinguish unwanted changes from valid recent work. Neither RDS nor a backup script can infer the workshop's intended business history.
On EC2, your team must arrange the database-consistent backup mechanism, scheduling, retention, access and restore environment. A filesystem or volume copy needs the appropriate coordination for the database engine; do not assume that copying files while the server writes to them produces a usable database. You can build excellent recovery on EC2, but someone must maintain and demonstrate it.
For either choice, record two practical targets: the amount of recent work the workshop can afford to lose and how long it can tolerate being unable to use the service. These are recovery point and recovery time objectives. Rehearse the full process, including credentials, application configuration, record checking and user acceptance. Measuring only the moment a resource becomes available leaves out the work that makes the recovered service useful.
8. Separate continued service, historical recovery and extra capacity
Three different complaints can sound like “the database is not good enough.” The workshop may lose access when infrastructure fails. It may need a record from before an accidental update. Or its reporting screen may become slow during a busy period. These complaints require different evidence and often different mechanisms.
A suitable Multi-AZ deployment can provide managed availability and failover capabilities. The exact behavior depends on the deployment type. A conventional Multi-AZ DB instance has a standby that does not serve ordinary application reads. A Multi-AZ DB cluster has a different arrangement with readable instances. Identify the selected design before describing where queries will run.
Failover is not a promise that every in-flight request will finish successfully. The application may need to discover the current destination, establish a connection and decide how to handle an uncertain operation. If an update was committed but the response was lost, blindly repeating it can create an application error. A managed database still needs a sensible application retry and transaction design.
A read replica can serve suitable read work where supported, but the application needs to send those queries to the intended reader. Asynchronous replication can mean a newly changed ticket is not visible immediately on the replica. A monthly report that tolerates a delay is different from a confirmation screen that must show the repair status just saved.
Storage autoscaling is another separate facility. It must be enabled and configured within supported limits. It does not rewrite inefficient queries, increase every other resource automatically or guarantee that storage can never fill. Observe growth, configured maximums and modification conditions. Increasing the space for records is different from making a complicated report execute faster.
For our repair workshop, write one requirement per line: keep accepting work after a supported failure, recover a mistakenly changed ticket, and finish the daily report within its target time. Then attach the proposed mechanism and acceptance test to each line. This makes it harder to mistake one feature name for a complete reliability design.
9. Choose from explicit requirements
RDS is a strong candidate when the application uses a supported engine and the team wants managed database operations within the service's boundaries. A small development team can spend more attention on the workshop's workflow when it does not also need to maintain every host-level database procedure. That advantage is strongest when the supported configuration matches the actual application.
MySQL on EC2 can be appropriate when a verified requirement needs control that the intended managed service does not provide. Examples to investigate include a required host integration, an unsupported engine build or a particular operational arrangement. These are investigation categories, not a claim that all plugins or custom settings are unavailable on RDS. Check the exact version and capability.
Write a decision record with the requirement, evidence, alternatives and ongoing owner. “The current application requires this host extension, tested on this version, and no acceptable supported alternative exists” is useful evidence. “EC2 is flexible” is only a general observation. Flexibility creates work as well as possibilities, so include the maintenance and recovery commitments it introduces.
Also consider the skills you are trying to learn. Installing a database on a disposable learning server can teach process management and host administration. Using RDS can teach managed-service configuration, application access and recovery choices. A teaching exercise does not automatically become the best production architecture, and a production decision does not make the other learning exercise worthless.
A responsible recommendation can have conditions. You might choose RDS after a successful compatibility rehearsal and a measured recovery test. You might choose EC2 while a required integration is being replaced, with a documented operator and review date. Explain the conditions so another engineer can tell when the decision should be reconsidered.
10. Compare the cost of the same outcome
Comparing one EC2 hourly figure with one RDS hourly figure leaves out much of the decision. First define the outcome: engine and version, capacity, storage behavior, availability, retention, monitoring and operating hours. A single unprotected database and a deployment with a recovery-tested availability design do not provide the same service.
List the relevant resource charges for each candidate using the current regional pricing and the actual configuration. Depending on the design, these can include instance capacity, storage, provisioned performance, backups, transfer and associated resources. Licensing and engine support choices can also affect the result. Record the date and assumptions with the estimate instead of presenting a remembered price as permanent.
Then include operational effort using your own team's estimate. The following numbers are fictional accounting units, not AWS prices or a prediction of your bill. Imagine candidate E has a resource estimate of 90 units per month and needs eight hours of routine work. Candidate R has a resource estimate of 145 units and needs three hours. If you value one hour of that work at 20 units, the illustrative totals are 250 and 205 units respectively.
This arithmetic does not prove that RDS is always cheaper. If the effort assumptions change, the result changes. Some teams already have effective database automation and experienced operators; others would have to build that capability. Likewise, the three-hour figure must not imply that a managed service requires no application monitoring, recovery testing or incident response.
Estimate exceptional work separately. A difficult engine upgrade or failed restore can consume time that a smooth month hides. Avoid inventing a precise financial value for every uncertain event. Instead, name the uncertainty, identify the evidence that would reduce it and show which parts of the decision depend on it. A transparent range is more useful than a deceptively exact total.
Finally, compare measured workload results. Paying less for a configuration that cannot complete the workshop's report or recover its records is not the same outcome at a lower price. Conversely, buying unused capacity does not improve a weak schema or missing recovery procedure. The goal is a suitable, supportable database service with understood costs.
11. Plan a move without losing the meaning of the data
Moving from MySQL on EC2 to RDS is more than replacing a hostname. Inventory the source version, database size, tables, character settings, users, privileges, jobs and features the application relies on. Check the target's compatibility and the supported migration methods. Record which work happens outside the database, such as a scheduled host script that produces an export.
Rehearse using an authorised non-production copy and an agreed data-handling procedure. For a small compatible database, a logical export and import may be suitable. Larger or more active systems may need a different method and a plan for changes made while data is being transferred. Choose from evidence about size, acceptable interruption and supported tooling rather than copying the shortest command from a tutorial.
Validate the candidate beyond its total row count. Two copies can both contain three tickets while disagreeing about whether a lathe is ready to use. Check identities, meaningful values, relationships, expected totals and representative application operations. Include text and time values that could reveal encoding or timezone mistakes. The next local lab demonstrates the equal-count trap with deliberately tiny records.
Decide how final writes are controlled during cutover. If the old application continues accepting work after the last copy, the target can already be stale when you switch. A plan may use a controlled write pause or a supported change-replication process with explicit final checks. The appropriate technique depends on the real system; a generic lesson cannot choose it from a hostname alone.
Keep rollback conditions precise. Before any new target writes, returning to the old source may be relatively straightforward if its state remains authoritative. After new work is committed only to the target, pointing the application back can hide or lose that work. The plan must explain how those new records are handled. “Change the connection string back” is not a complete rollback strategy.
After cutover, verify the application using its normal account and connection settings. Create a designated test ticket, retrieve it, update it as intended and verify any dependent report. Confirm that the application is using the intended target and that monitoring, backups and operational ownership are active. Retire the old environment only when the approved retention and acceptance conditions are satisfied.
12. Turn a responsibility list into useful evidence
For each important operation, record four things: the trigger, the person or team accountable, the mechanism and the evidence of success. For example, the trigger may be a mistaken ticket update. The application owner is accountable for deciding which information is correct. The recovery mechanism may be an RDS restore into a separate destination. Evidence includes checked ticket identities and a successful application operation.
This format prevents a common gap in shared responsibility. Writing “AWS handles backups” names part of the mechanism but does not identify who will select a recovery point or verify the workshop's records. Writing “the developer handles everything” is equally unhelpful if there is no procedure or realistic time allocation. Responsibilities need enough detail that another person can act when the original author is unavailable.
Use a small review table before a deployment. Include maintenance acceptance, credential rotation, capacity alerts and recovery rehearsal. A row with no owner is unfinished. A row with an owner but no observable result is also unfinished. A successful service API call can be part of the evidence, but it cannot replace checking the outcome students or staff actually need.
Keep the record proportionate. A classroom exercise can use fictional names and a short checklist. A real workshop service needs the team's actual operating arrangements. The purpose is not to produce paperwork for its own sake; it is to uncover the point where an otherwise reasonable design depends on an assumption nobody has tested.
13. Lab: prove that matching counts can hide incorrect records
This exercise uses Python 3 with its SQLite module on your own computer. It creates fictional repair tickets in a temporary directory and removes that directory when it finishes. It does not connect to AWS, migrate a MySQL database or measure RDS behavior. Its purpose is to make data acceptance visible: you will reject a candidate that looks correct when judged only by its row count.
- Save the displayed code in a new file named
repair_validation.py. Keep it separate from any real database project. - Before running it, predict which comparison will fail. Ticket 101 has the same identity in both databases but a different status.
- Run
python3 repair_validation.pyin a terminal. Read each result in order rather than treating the final exit as the whole experiment. - Explain why the candidate becomes stale after the new source write. The earlier passing result described an earlier moment, not every future state.
- Check the cleanup message. All database paths belong to the temporary directory created by this script.
from pathlib import Path
from tempfile import TemporaryDirectory
import sqlite3
SCHEMA = '''CREATE TABLE tickets (
ticket_id INTEGER PRIMARY KEY,
equipment TEXT NOT NULL,
status TEXT NOT NULL
)'''
SEED = [(101, 'Lathe A', 'reported'),
(102, 'Meter B', 'inspected'),
(103, 'Pump C', 'completed')]
def make_database(path):
con = sqlite3.connect(path)
try:
con.execute(SCHEMA)
con.executemany('INSERT INTO tickets VALUES (?, ?, ?)', SEED)
con.commit()
finally:
con.close()
def rows(path):
# mode=ro rejects a missing file instead of creating an empty database.
con = sqlite3.connect(path.resolve().as_uri() + '?mode=ro', uri=True)
try:
return con.execute(
'SELECT ticket_id, equipment, status FROM tickets ORDER BY ticket_id'
).fetchall()
finally:
con.close()
def change(path, sql, values):
con = sqlite3.connect(path)
try:
con.execute(sql, values)
con.commit()
finally:
con.close()
with TemporaryDirectory(prefix='repair-validation-') as directory:
root = Path(directory)
source, candidate = root / 'source.db', root / 'candidate.db'
make_database(source)
make_database(candidate)
change(candidate, 'UPDATE tickets SET status=? WHERE ticket_id=?',
('completed', 101))
a, b = rows(source), rows(candidate)
assert len(a) == len(b) == 3
assert a != b
print('Equal row count; wrong ticket status: REJECT')
change(candidate, 'UPDATE tickets SET status=? WHERE ticket_id=?',
('reported', 101))
assert rows(source) == rows(candidate)
print('Three identities and values match: PASS for this small check')
change(source, 'INSERT INTO tickets VALUES (?, ?, ?)',
(104, 'Drill D', 'reported'))
assert rows(source) != rows(candidate)
print('New source write after comparison: candidate is STALE')
assert not (root / 'missing.db').exists()
try:
rows(root / 'missing.db')
except sqlite3.OperationalError:
print('Missing database path: REJECT; no empty file created')
else:
raise AssertionError('Missing database unexpectedly opened')
assert not (root / 'missing.db').exists()
# Leave the mismatch visible; do not pretend a stale target is accepted.
assert not root.exists()
print('Temporary databases cleaned')
The first result rejects the candidate even though both copies contain three rows. This is the key observation: counting records answers how many, not whether their meanings agree. The comparison selects the same columns in a stable identity order, so a changed status is visible. In a real migration you would also define checks for every relevant table, relationship, data type and business rule.
The second result passes only the small comparison in this exercise. The script then adds ticket 104 to the source and deliberately leaves the target stale. This models a planning issue, not a replication mechanism. You have not synchronized the databases or implemented a production cutover by running this script. You have demonstrated why continued source writes need an explicit migration plan.
The missing-path test provides a separate lesson. SQLite normally can create a database when asked to connect to a new path. Here the inspection function uses a read-only URI, so an incorrect location fails instead of silently producing a new empty database. For an RDS application, the equivalent investigative habit is to verify the intended endpoint, logical database and account rather than accept any successful connection.
For your lab notes, record the initial mismatch, the corrected comparison and the later stale state. Identify the exact event that invalidated the previous acceptance result. A useful answer names ticket 104 and the source write; “the databases are different” describes the symptom without explaining the cause.
14. Lab: replace an application release while retaining its record
This second offline exercise separates two lifetimes: an application release and the data it reads. Blue and green are simply names for two temporary release directories. Both read the same fictional ticket from a separate data directory. The exercise then removes the old release and confirms that the record remains readable through the new release.
Save this code as repair_lifetime.py and run it with python3 repair_lifetime.py. Predict the result before removing the blue directory. Then identify the path that the green release needs in order to find the record.
from pathlib import Path
from tempfile import TemporaryDirectory
import sqlite3
def read_ticket(database, release_directory):
release = (release_directory / 'release.txt').read_text().strip()
con = sqlite3.connect(database.resolve().as_uri() + '?mode=ro', uri=True)
try:
ticket = con.execute(
'SELECT equipment, status FROM tickets WHERE ticket_id=?', (101,)
).fetchone()
if ticket is None:
raise LookupError('Required ticket missing')
return release, ticket
finally:
con.close()
with TemporaryDirectory(prefix='repair-lifetime-') as directory:
root = Path(directory)
data = root / 'data'
data.mkdir()
database = data / 'workshop.db'
con = sqlite3.connect(database)
try:
con.execute('CREATE TABLE tickets (ticket_id INTEGER PRIMARY KEY, equipment TEXT, status TEXT)')
con.execute('INSERT INTO tickets VALUES (?, ?, ?)',
(101, 'Lathe A', 'reported'))
con.commit()
finally:
con.close()
blue, green = root / 'release-blue', root / 'release-green'
for release in (blue, green):
release.mkdir()
(release / 'release.txt').write_text(release.name)
first = read_ticket(database, blue)
second = read_ticket(database, green)
assert first[0] != second[0] and first[1] == second[1]
print('Different application release, same retained ticket:', second)
(blue / 'release.txt').unlink()
blue.rmdir()
assert read_ticket(database, green)[1] == ('Lathe A', 'reported')
print('Old release removed; separate record still readable')
try:
read_ticket(green / 'workshop.db', green)
except sqlite3.OperationalError:
print('Wrong database location rejected')
else:
raise AssertionError('Wrong database location unexpectedly worked')
assert not (green / 'workshop.db').exists()
assert not root.exists()
print('Temporary application and data directories cleaned')
The two application labels differ, but their ticket values match because they read the same database file. Removing the blue directory does not remove the sibling data directory. This is a concrete model of separating application deployment artifacts from retained information. The final negative check rejects a guessed database path inside the green release.
Both directories still exist on one computer during the exercise. A disk failure could affect both. Therefore this lab does not demonstrate RDS availability, remote network access, storage durability or a backup policy. Those require different mechanisms and tests. State that limit in your notes so the useful lifetime lesson does not turn into an incorrect claim about failure isolation.
As a follow-up task, draw the equivalent components for an EC2 application using RDS: application release, configured database endpoint, authentication method and retained records. Mark which component is replaced during an application release. Then describe one configuration mistake that would stop the new release from reading the existing tickets even though the database remains healthy.
15. Interview questions with explained answers
1. A team already runs MySQL on EC2. Explain the practical reason to consider RDS.
The team should compare operational responsibilities and application requirements. RDS supplies managed facilities for running a supported database engine, reducing host-level work the team otherwise owns. The team still designs queries, access and application behavior, and tests recovery. A strong answer checks compatibility and the required outcome before recommending a move. It does not claim that simply moving the same inefficient query will make it fast.
2. Does RDS require the application and database to be in different subnets?
No universal rule says an EC2 application must use a different subnet from the RDS instance. Placement follows the chosen VPC, DB subnet group and supported deployment requirements. Many designs separate application and database subnets for deliberate network organization, but that is different from saying RDS always forces it. Explain the intended route, security groups and database access instead of inferring connectivity from subnet names alone.
3. The RDS security group permits the application. Can it now update every table?
No. The network permission only addresses a part of reachability. The client must reach the intended endpoint, authenticate with a supported database identity and have the SQL privileges required for that operation. The account should normally have a limited purpose. An AWS identity that can modify the DB instance is also not automatically an unrestricted database user. Describe each boundary separately when troubleshooting.
4. Why can a recovery plan remain incomplete even with automated backups enabled?
The team must know the available recovery history, select an appropriate destination and verify the recovered information. It must also handle valid work that happened after the selected recovery point. A restore result alone does not decide which ticket statuses are correct or switch the application safely. A complete plan assigns ownership, rehearses the application checks and measures the service's actual recovery objectives.
5. A migration copied the same number of rows. Is that enough to approve cutover?
No. Equal counts can hide changed identities, wrong values, missing relationships or a copy that became stale after comparison. Use checks tied to the application's meaning and the migration's agreed write-control point. The lab's two three-row databases disagree about ticket 101. Even after that difference is corrected, a new source ticket invalidates the earlier equality result. Acceptance evidence has a time and a scope.
6. When could a self-managed database still be a reasonable choice?
A verified requirement may need a host integration, engine build or other capability that the intended managed configuration does not provide. The decision should identify that requirement precisely and assign the resulting maintenance, backup, security and recovery work. EC2 can support a well-operated database; the important point is that the operating responsibilities remain with the team. General flexibility alone is not evidence that the added work is justified.
16. Check your reasoning
Choose an answer before opening each explanation. The aim is to connect the observed problem to the correct boundary, not to memorize a slogan about managed services.
1. Two databases have 40 tickets each, but one ticket has the wrong owner. Accept or reject the candidate?
Reject it for that acceptance check. The count agrees, but an application-relevant value differs. Investigate the source, expected value and transfer process before approval. A matching total cannot overrule a known record-level error.
2. Removing an application release leaves a separately stored record intact. Have you proved disaster recovery?
No. You proved that this release removal did not delete this separate data path. You have not tested disk failure, historical restoration or the recovery time objective. Keep the conclusion within the experiment's evidence.
3. A reporting query is slow. Should enabling storage autoscaling be the automatic first fix?
No. Determine whether storage capacity is actually the limiting problem. Query design, indexes, waits, connections and compute demand can affect response time. Storage growth facilities answer a different question from efficient execution.
4. Standard RDS lacks a needed host operation. Does RDS Custom automatically solve that for MySQL?
No. RDS Custom is not a general MySQL host-access setting. Its documented engine scope includes SQL Server and Oracle, with Oracle support and access scheduled to end on 31 March 2027. Verify the specific requirement and supported alternatives before selecting a service.
5. After new tickets are written only to the target, is changing back to the old endpoint a complete rollback?
No. The old source may lack those tickets. A rollback plan must account for new target work and identify the authoritative state. Redirecting connections changes where requests go; it does not reconcile records by itself.
17. Revision cards and independent tasks
- Managed operation
- A service boundary that changes who operates infrastructure and supported database facilities. It does not remove application correctness or recovery acceptance.
- Separate lifetime
- Application releases and retained data can be managed independently. Verify the actual storage and deletion arrangement rather than assume separation from a diagram.
- Compatibility evidence
- The named engine version, feature and tested application behavior that justify a service choice. General statements about flexibility are insufficient.
- Useful recovery
- Recovered records, an accepted application operation and understood recent-data gaps. Resource availability is only part of the result.
- Cutover evidence
- Checks tied to the intended target and the controlled write boundary. A passing comparison can become stale when the source changes.
- Fair cost comparison
- Equivalent capacity, availability and recovery outcomes, including relevant resource charges and realistic operating effort.
Task 1: Prepare a one-page recommendation for the fictional workshop. Include three requirements, the proposed database arrangement, one rejected alternative and the evidence needed before approval. Another student should be able to identify the remaining uncertainties without asking you to explain them verbally.
Task 2: Make a four-row responsibility table for maintenance, access, capacity and recovery. For each row name a trigger, accountable role, mechanism and observable result. Replace vague results such as “it works” with a specific operation involving a repair ticket.
Task 3: Rework the fictional cost example with different effort estimates. Keep the resource assumptions unchanged first, then change one resource assumption. Explain which change alters the recommendation and which requirement still needs a technical test. Do not label the invented units as real AWS prices.
Task 4: Present the migration lab to a classmate without showing the output first. Ask them to predict the equal-count result and the effect of ticket 104. A successful explanation connects each printed conclusion to the operation that caused it and states what the small experiment cannot prove.
Primary sources
- RDS overview and shared responsibilities
- DB instances and logical databases
- RDS Custom scope
- RDS Custom for Oracle end of support and access
- DB instance maintenance
- Database authentication
- VPC placement and DB subnet groups
- Automated backups
- Point-in-time recovery into a new instance
- Multi-AZ deployment types
- Read replicas
- Storage autoscaling capabilities and limits
- DB instance billing
- MySQL migration planning pattern
- Python SQLite connections and queries