AWS Database Services | RDS, DynamoDB, Redshift, Aurora | Sinhala Guide
ආයුබෝවන් හැමෝටම! 👋 Cloud Computing කියන්නේ අද වෙනකොට software development වලදී අත්යවශ්ය දෙයක් වෙලා. ඒ අතරින් data manage කරන එක, ඒ කියන්නේ databases කියන එක, ඕනෑම application එකක හදවත වගේ. ඉතින්, Amazon Web Services (AWS) කියන්නේ මේ database services ගොඩක් දෙනවා, ඒවා මොනවද කියලා හරියටම තේරුම් ගන්න එක අපේ වැඩ පහසු කරගන්න ගොඩක් වැදගත්.
සාමාන්යයෙන් අපිට database එකක් හදන්න කිව්වොත් server එකක් අරන්, OS එක දාලා, database software එක install කරලා, ඒක maintain කරන්නත් වෙනවා. ඒත් AWS වගේ Cloud platform එකකින් මේ හැම දේම manage කරලා දෙනවා. ඒක නිසා අපිට data වලට අදාළ core functionalities ගැන විතරක් හිතලා වැඩ කරන්න පුළුවන්.
මේ tutorial එකෙන් අපි AWS වල තියෙන ප්රධාන database services කිහිපයක් ගැන පැහැදිලිව කතා කරනවා. Relational databases වලට Amazon RDS සහ Aurora, NoSQL databases වලට DynamoDB, Data Warehousing වලට Redshift, සහ In-memory caching වලට ElastiCache වගේ services ගැන අපි විස්තරාත්මකව බලමු. ඒ වගේම, පවතින database එකක් AWS Cloud එකට migrate කරගන්නේ කොහොමද කියලත් කෙටියෙන් අපි බලමු. එහෙනම්, අපි පටන් ගමු නේද?
1. ඇයි AWS Databases? Cloud Computing වල වාසි
Cloud එකේ databases use කරන එකට ගොඩක් වාසි තියෙනවා. සාම්ප්රදායිකව (on-premises) database එකක් maintain කරන එකට වඩා මේක ගොඩක් පහසුයි, කාර්යක්ෂමයි.
- Managed Service: AWS විසින් hardware provisioning, setup, patching, backups, scaling වගේ ගොඩක් වැඩ manage කරනවා. ඒකෙන් අපිට infrastructure maintenance ගැන හිතන්නේ නැතුව application development වලට concentrate කරන්න පුළුවන්.
- Scalability: අපේ application එකේ user base එක වැඩි වෙනකොට, data ප්රමාණය වැඩි වෙනකොට, database එකේ capacity එක වැඩි කරගන්න පුලුවන් පහසුවෙන්. ඒ වගේම demand අඩු වෙනකොට ආපහු අඩු කරන්නත් පුළුවන්.
- High Availability & Durability: AWS databases design කරලා තියෙන්නේ ඉහළ availability සහ durability තියෙන්න. ඒ කියන්නේ database downtime අඩුයි, data නැති වෙන්නේ නැහැ කියන එක.
- Security: AWS provides a robust security framework. Access control, encryption at rest and in transit, network isolation වගේ දේවල් වලින් අපේ data ආරක්ෂා වෙනවා.
- Cost-Effectiveness: අපිට ඕන කරන resources වලට විතරයි ගෙවන්න ඕනේ (pay-as-you-go). High initial investment අවශ්ය වෙන්නේ නැහැ.
2. Relational Databases (SQL) on AWS
Relational databases කියන්නේ structured data manage කරන්න use කරන සාම්ප්රදායික database වර්ගයක්. මේවා tables වලින් සමන්විතයි, ඒ tables අතර relationships තියෙනවා. AWS වල මේවාට ප්රධාන services දෙකක් තියෙනවා: Amazon RDS සහ Amazon Aurora.
2.1 Amazon Relational Database Service (RDS)
Amazon RDS කියන්නේ popular relational databases පහසුවෙන් set up කරන්න, operate කරන්න, සහ scale කරන්න පුළුවන් managed service එකක්. මේකෙන් අපිට admin tasks ගොඩක් AWS එකට බාර දෙන්න පුළුවන්.
RDS මගින් support කරන database engines:
- MySQL
- PostgreSQL
- Oracle
- Microsoft SQL Server
- MariaDB
RDS වල වාසි:
- Automated Backups: RDS automatically backups ගන්නවා, අපිට restore කරන්න පුළුවන්.
- Patching: Operating system සහ database software patching AWS විසින් manage කරනවා.
- Scaling: Storage සහ compute capacity එක වෙනස් කරන්න පුළුවන්. Read Replicas වලින් read-heavy workloads වලට performance වැඩි කරන්න පුළුවන්.
- Multi-AZ Deployment: High availability සහ disaster recovery වලට උපකාරී වෙනවා. Primary database instance එක fail වුණොත්, standby instance එකට switch වෙනවා.
සරල RDS භාවිත උදාහරණයක්:
අපි හිතමු අපිට web application එකක් තියෙනවා, ඒකට MySQL database එකක් ඕනේ කියලා. AWS Management Console එකට ගිහින් RDS service එකට ගියාම අපිට පහසුවෙන් database instance එකක් create කරන්න පුළුවන්.
1. Choose an engine: MySQL
2. Choose instance type: (e.g., db.t3.medium for development)
3. Configure settings: Database name, Master username, Password.
4. Set up network and security: VPC, Security Groups.
5. Create Database.මේ දේවල් දුන්නම AWS විසින් අපිට සම්පූර්ණයෙන්ම ක්රියාත්මක වෙන MySQL database instance එකක් හදලා දෙනවා. අපිට අවශ්ය වන්නේ ඒකේ endpoint එක අරන් අපේ application එකට connect කරන එක විතරයි.
2.2 Amazon Aurora
Amazon Aurora කියන්නේ MySQL සහ PostgreSQL එක්ක compatible වෙන, AWS විසින් design කරපු enterprise-grade relational database එකක්. මේක සාම්ප්රදායික MySQL databases වලට වඩා 5 ගුණයක් වේගවත්, PostgreSQL වලට වඩා 3 ගුණයක් වේගවත් කියලා AWS කියනවා. ඒ වගේම, commercial databases වල තියෙන availability සහ reliability මේකෙන් ලබා දෙනවා, නමුත් open-source databases වල cost effectiveness එකත් එක්ක.
Aurora වල විශේෂතා:
- High Performance: Unique, distributed, fault-tolerant storage system එකක් නිසා වේගවත්.
- Scalability: ගබඩා ධාරිතාව (storage) 128TB දක්වා auto-scale වෙනවා. Read Replicas 15ක් දක්වා support කරනවා.
- High Availability: 99.99% availability සඳහා design කරලා තියෙනවා. Multi-AZ deployment automatically වෙනවා.
- Cost-Effective: Commercial database performance එකක් ලබා දෙනවා, නමුත් on-demand prices යටතේ.
- Serverless Option: Aurora Serverless කියන්නේ database capacity එක automatically adjust කරන option එකක්. ඒක නිසා අපි use කරනවාට විතරක් ගෙවන්න පුළුවන්.
ඔබේ application එකට high performance සහ scalability අවශ්ය නම්, ඒ වගේම MySQL/PostgreSQL compatibility අවශ්ය නම්, Aurora කියන්නේ නියම තේරීමක්.
3. Non-Relational Databases (NoSQL) on AWS
NoSQL databases කියන්නේ unstructured, semi-structured, සහ structured data manage කරන්න use කරන database වර්ගයක්. මේවා scalable, flexible, සහ high performance requirements තියෙන applications වලට ගොඩක් හොඳයි. AWS වල ප්රමුඛතම NoSQL service එක තමයි Amazon DynamoDB.
3.1 Amazon DynamoDB
Amazon DynamoDB කියන්නේ AWS විසින් ලබා දෙන fully managed, serverless, key-value and document database එකක්. මේක single-digit millisecond performance එකක් ඕනෑම scale එකකදී ලබා දෙනවා. ඒ කියන්නේ, Facebook, Netflix වගේ massive scale applications වලටත් මේක පාවිච්චි කරන්න පුළුවන්.
DynamoDB වල ප්රධාන විශේෂාංග:
- Serverless: Infrastructure management ගැන හිතන්න ඕනේ නැහැ. AWS විසින් scaling, patching, maintaining වගේ දේවල් manage කරනවා.
- High Performance: Consistent single-digit millisecond latency එකක් දෙනවා. In-memory cache එකක් වන DAX (DynamoDB Accelerator) එක්ක මේ performance එක තව වැඩි කරන්න පුළුවන්.
- Scalability: Throughput (read/write capacity) සහ storage capacity එක 자동으로 adjust වෙනවා.
- Durability and Availability: Multi-AZ deployment නිසා data durability සහ availability සහතික වෙනවා.
- Flexible Schema: Relational databases වගේ rigid schema එකක් නැහැ. ඒ නිසා data structures වෙනස් කරන එක පහසුයි.
DynamoDB භාවිත උදාහරණයක් (Python Boto3):
අපි හිතමු අපිට user details store කරන්න ඕනේ කියලා. DynamoDB table එකක Users කියලා item එකක් (row) create කරගන්න පුළුවන්.
import boto3
# AWS region එක Specify කරන්න
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')
# Table එකේ නම
table = dynamodb.Table('Users')
# නව User item එකක් add කරන්න
try:
response = table.put_item(
Item={
'UserId': 'user_12345',
'Username': 'saman_perera',
'Email': '[email protected]',
'Age': 30,
'City': 'Colombo'
}
)
print("User 'saman_perera' added successfully!")
print(response)
except Exception as e:
print(f"Error adding user: {e}")
# Item එකක් retrieve කරගන්න
try:
response = table.get_item(
Key={
'UserId': 'user_12345'
}
)
item = response.get('Item')
if item:
print("\nRetrieved user details:")
print(item)
else:
print("\nUser not found.")
except Exception as e:
print(f"Error retrieving user: {e}")
මේ වගේ සරලව Python Boto3 library එක භාවිතා කරලා DynamoDB එක්ක වැඩ කරන්න පුළුවන්. UserId කියන්නේ අපේ Primary Key එක. ඒක unique වෙන්න ඕනේ.
4. Data Warehousing සහ Analytics
විශාල data ප්රමාණයක් analyze කරලා business insights ලබා ගන්න ඕන වෙන තැන් වලට data warehouses අවශ්ය වෙනවා. AWS වල මේකට තියෙන ප්රධානම service එක තමයි Amazon Redshift.
4.1 Amazon Redshift
Amazon Redshift කියන්නේ fully managed, petabyte-scale data warehouse service එකක්. මේක designed කරලා තියෙන්නේ විශාල data sets ඉක්මනින් analyze කරන්න, business intelligence queries run කරන්න. සාමාන්ය databases වලට වඩා මේක analytics workloads වලට ගොඩක් optimised.
Redshift වල විශේෂාංග:
- Columnar Storage: Redshift data store කරන්නේ columns වලින්. ඒක නිසා analytical queries (aggregations, sums, averages) වලට ගොඩක් වේගවත්.
- Massively Parallel Processing (MPP): Data nodes කිහිපයක් හරහා queries distribute කරලා, parallel processing වලින් වේගවත් ප්රතිඵල ලබා දෙනවා.
- Scalability: Storage සහ compute capacity එක වෙනස් කරන්න පුළුවන්.
- Cost-Effective: Data warehouse එකක් on-premises maintain කරනවාට වඩා ලාභදායීයි.
ඔබට sales data, customer behavior data, sensor data වගේ විශාල data sets analyze කරන්න අවශ්ය නම්, Redshift කියන්නේ ඉතා හොඳ තේරීමක්.
5. In-Memory Caching
Application එකක performance එක වැඩි කරගන්න, database load එක අඩු කරගන්න In-Memory caching කියන්නේ හොඳ solution එකක්. AWS වල මේකට තියෙන්නේ Amazon ElastiCache.
5.1 Amazon ElastiCache
Amazon ElastiCache කියන්නේ in-memory data store එකක්. මේක database එකෙන් නිතරම retrieve කරන data cache කරලා තියාගන්න use කරනවා. ඒක නිසා application එකට database එකට හැම වෙලාවෙම query කරන්න ඕනේ නැහැ, cache එකෙන් ඉක්මනට data retrieve කරගන්න පුළුවන්.
ElastiCache support කරන in-memory engines:
- Redis: Advanced data structures (lists, sets, hashes), publish/subscribe functionality, replication වගේ දේවල් support කරනවා. Session caching, leaderboards, real-time analytics වලට හොඳයි.
- Memcached: Simple key-value store එකක්. Object caching වලට හොඳයි. Multiple cores support කරනවා.
ElastiCache වල වාසි:
- Improved Performance: Database එකට යන requests ප්රමාණය අඩු කරලා application response times අඩු කරනවා.
- Reduced Database Load: Database එක මත ඇති වන බර අඩු කරනවා.
- Scalability: Caching capacity එක පහසුවෙන් scale කරන්න පුළුවන්.
- Fully Managed: AWS විසින් patching, backup, recovery වගේ දේවල් manage කරනවා.
ElastiCache භාවිතය (Conceptual):
අපි හිතමු අපේ web application එකේ product catalog එකක් තියෙනවා, ඒකේ product details database එකේ තියෙනවා. හැම user request එකකටම database එකට ගිහින් product details අරන් එනවා වෙනුවට, ElastiCache එකේ මේ details cache කරලා තියාගන්න පුළුවන්.
# Example: Product details cache
def get_product_details(product_id):
# මුලින්ම cache එකේ බලනවා product details තියෙනවද කියලා
product_details = cache.get(f"product:{product_id}")
if product_details:
print("Product details found in cache!")
return product_details
else:
# Cache එකේ නැත්නම් database එකෙන් ගන්නවා
print("Product details not found in cache, fetching from DB...")
product_details = db.get_product(product_id) # Database query
# Database එකෙන් ගත්තට පස්සේ cache එකේ store කරනවා
cache.set(f"product:{product_id}", product_details, expiry=3600) # 1 hour expiry
return product_details
මේ වගේ architecture එකකින් database load එක අඩු කරලා application response time එක ගොඩක් අඩු කරන්න පුළුවන්. ඒකෙන් user experience එකත් වැඩි වෙනවා.
6. Database Migration Strategies
දැනට on-premises හෝ වෙනත් cloud platform එකක තියෙන database එකක් AWS Cloud එකට migrate කරගන්න එකත් ගොඩක් වෙලාවට අවශ්ය වෙනවා. AWS මේකට ගොඩක් පහසුකම් සලසනවා.
6.1 AWS Database Migration Service (DMS)
AWS DMS කියන්නේ database migration process එක පහසු කරන service එකක්. මේකෙන් homogeneous (e.g., MySQL to Aurora MySQL) සහ heterogeneous (e.g., Oracle to PostgreSQL) migrations දෙකම support කරනවා.
Migration Strategies:
- Homogeneous Migrations: Source සහ target database engines දෙකම එක හා සමානයි (e.g., MySQL to MySQL on RDS). මේවාට AWS DMS වලට අමතරව native tools (backup/restore) වුණත් use කරන්න පුළුවන්.
- Heterogeneous Migrations: Source සහ target database engines වෙනස් (e.g., Oracle to PostgreSQL). මේවාට AWS Schema Conversion Tool (SCT) වගේ tools අවශ්ය වෙනවා schema එක convert කරගන්න.
DMS මගින් support කරන migration types:
- Full Load: Source database එකේ තියෙන data ටික සම්පූර්ණයෙන්ම target database එකට copy කරනවා.
- Change Data Capture (CDC): Full Load එකෙන් පස්සේ source database එකේ වෙනස් වෙන data ටික real-time target database එකට sync කරනවා. ඒක නිසා downtime එක minimize කරන්න පුළුවන්.
Migration කරනකොට හොඳ planning එකක් අත්යවශ්යයි. Data integrity, network latency, security, සහ downtime requirements වගේ දේවල් ගැන සැලකිලිමත් වෙන්න ඕනේ.
නිගමනය (Conclusion)
ඉතින් යාලුවනේ, මේ tutorial එකෙන් අපි AWS වල තියෙන ප්රධාන database services කිහිපයක් ගැන හොඳ අවබෝධයක් ලබා ගත්තා කියලා මම හිතනවා. Relational databases (RDS, Aurora) තියෙනවා structured data වලට, NoSQL databases (DynamoDB) තියෙනවා high-scale, flexible data වලට, Data Warehousing (Redshift) තියෙනවා analytics වලට, සහ Caching (ElastiCache) තියෙනවා performance එක වැඩි කරගන්න.
මේ හැම service එකක්ම AWS Cloud එකේ fully managed නිසා, අපිට Infrastructure management ගැන හිතන්නේ නැතුව අපේ application එකේ core business logic එකට focus කරන්න පුළුවන්. ඒකෙන් අපේ productivity එක වැඩි වෙනවා වගේම, අපිට scalable, secure, සහ high-performing applications develop කරන්නත් පුළුවන්.
මතක තියාගන්න, application එකක requirements වලට අනුව නිවැරදි database service එක තෝරා ගැනීම ගොඩක් වැදගත්. ඒ නිසා මේ services ගැන තවදුරටත් research කරලා, ඔබේ project වලට ගැලපෙනම එක තෝරා ගන්න උත්සාහ කරන්න.
ඔබේ අදහස්, ප්රශ්න, හෝ මේ services වලින් ඔබේ අත්දැකීම් පහත comments section එකේ සඳහන් කරන්න. තවත් මේ වගේ ප්රයෝජනවත් tutorial එකකින් හමුවෙමු! 🚀