Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Redis

เพิ่มประสิทธิภาพ Azure SQL ด้วย Azure Cache for Redis

หนึ่งในผลกระทบ terbesarต่อการใช้ทรัพยากรของ Azure SQL DB คือการดึงข้อมูลซ้ำๆ โดย application layer ไม่ว่าจะ query เร็วแค่ไหน การเรียก procedure เดียวกันหรือออก SQL statements เดียวกันหลายร้อย หลายพัน หรือหลายล้านครั้งต่อวัน สามารถทำลายประสิทธิภาพฐานข้อมูลได้ "ตายจากแผลเล็กๆ หลายพันแผล" สามารถทำให้ระบบล้มง่ายๆ บางครั้ง DBAs ยากที่จะ troubleshoot เพราะการ execute statements เกิดเร็วจนไม่โชว์ใน tools อย่าง sp_whoisactive ต้อง dive เข้าไปใน Query Performance Insights หรือ Query Store จึงเห็นปัญหาจริง

Azure Portal

เพิ่มประสิทธิภาพ Azure SQL ด้วย Azure Cache for Redis

เพิ่มประสิทธิภาพ Azure SQL ด้วย Azure Cache for Redis

SSMS Query Store Top Consuming Queries with Executions Count Metric

เพิ่มประสิทธิภาพ Azure SQL ด้วย Azure Cache for Redis

เพิ่มประสิทธิภาพ Azure SQL ด้วย Azure Cache for Redis

คำถามคือ จะแก้ปัญหานี้อย่างไร? โค้ดปรับให้เหมาะสมแล้ว รันที่ optimal performance แค่ volume ของ application calls ที่ก่อให้เกิดปัญหา คำตอบหนึ่งคือ Azure Cache for Redis

Azure Cache for Redis คืออะไร?

ง่ายๆ คือ dedicated memory cache data store ที่เข้าถึงได้จากแอปพลิเคชันภายในหรือภายนอก Azure บน open source Redis มันช่วยให้คุณโหลดข้อมูลลง in-memory data store อ่านโดยตรงจากนั้น และลดจำนวนการเรียก database การวางข้อมูลใน cache layer นี้ป้องกันไม่ให้แอปพลิเคชันต้องทำ repeatable data calls ซ้ำๆ สามารถปรับปรุง database performance อย่างมาก ลด latency และปลดทรัพยากรสำหรับ data requests อื่นๆ โดยย้าย performance load ไปที่ cache และห่างจาก database layer นี้จะต้องเปลี่ยน application code แต่สามารถเพิ่ม database performance ได้จริง ดูตัวอย่างแอปซับซ้อนใน Microsoft docs

นี่อาจเป็นประโยชน์ทั้ง performance และ monetary ผลลัพธ์อาจทำให้คุณ scale down Azure SQL Databases ได้ เพราะ resource consumption จะลดลง

เริ่มต้นใช้งาน (Getting Started)

Create a Resource → Under Databases เลือก Azure Cache for Redis

เพิ่มประสิทธิภาพ Azure SQL ด้วย Azure Cache for Redis

สนใจ cache type options คลิก link pricing tiers เพื่อเลือกที่เหมาะกับ environment ในที่นี้เลือก Basic C0 ที่ถูกที่สุด ได้ 250 MB cache ประมาณ $15 ต่อเดือน ตัวใหญ่กว่าอาจแพงขึ้น

เพิ่มประสิทธิภาพ Azure SQL ด้วย Azure Cache for Redis

สำหรับ Networking เลือก Public หรือ Private Endpoint แล้ว Next

เพิ่มประสิทธิภาพ Azure SQL ด้วย Azure Cache for Redis

เลือก Redis version (มี version 6 ใน Preview) Next ไป Tag options (ข้าม) 最后 Review และ Create resource

ตอนนี้มี Redis Cache resource แล้ว ยังมีหลายขั้นตอนเพื่อใช้งาน จัดเก็บข้อมูล และเข้าถึงผ่านแอปพลิเคชัน ผมจะทิ้งขั้นตอนเหล่านั้นให้คุณ ในโพสต์นี้แค่แสดงว่าหาได้ที่ไหนใน portal และสร้างอย่างไร

สรุป

หากคุณทำงานใน environment ที่มี repeated data calls หลายพันครั้งต่อชั่วโมง นี่อาจเป็น resource ที่ยอดเยี่ยมสำหรับคุณ ขอแนะนำเพิ่ม Azure Cache for Redis ใน performance tuning tool kit ของคุณ ข้อมูลทั้งหมดที่ต้องการต่อไปอยู่ที่นี่ อ่าน security considerations ด้วย มี documentation ที่มีประโยชน์ใน Microsoft docs

No