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

Oracle TimesTen: ฐานข้อมูล In-Memory ระดับอัลตราเร็วสำหรับประสิทธิภาพสูงสุด

TimesTen History

• ประดิษฐ์ที่ HP Labs ในปี 1994

• ถูกฝังใน HP's Open Call solution

• แยกออกมาในปี 1996 เป็น VC funded startup

• พันรายของ production customers

• ถูกซื้อโดย Oracle Corporation ในปี 2005

• 3 major releases ตั้งแต่ 2005: 6.0, 7.0, 11gR2, 18c Release 1

ภาพรวมของ Oracle TimesTen

Oracle TimesTen In-Memory Database เป็นระบบจัดการฐานข้อมูลเชิงสัมพันธ์ในหน่วยความจำ (in-memory) ที่มี persistence และ high availability ถูกออกแบบและนำไปใช้งานที่ Hewlett-Packard labs ใน Palo Alto, California TimesTen spun out เป็น startup แยกต่างหากในปี 1996 และถูกซื้อโดย Oracle Corporation ในปี 2005

TimesTen databases มี persistence และ availability สูง ให้ very low latency และ high throughput เนื่องจากเป็น in-memory database ฟีเจอร์อื่นๆ รวมถึง standard relational database APIs เช่น JDBC และ ODBC TimesTen ไม่ได้ใช้แค่ standalone in-memory database แต่ยังให้ประโยชน์ในการใช้เป็น cache ใน relational databases อื่นๆ รวมถึง Oracle Database เอง มักใช้ใน OLTP applications ปริมาณสูงมาก รวมถึง financial trading และ telecom billing

How TimesTen Stores Data on Disk

Image source: https://luna-ext.di.fc.ul.pt/oracle11g/timesten.112/e14261/overview.htm

แต่ละ TimesTen data store มี checkpoint files สองไฟล์พอดี Checkpoint ถูกเรียกทุก 10 นาทีโดยค่าเริ่มต้น ซึ่งเขียน dirty memory pages ไปยัง checkpoint file แรก และ checkpoint ถัดไปใช้ checkpoint file อีกไฟล์ Write transactions ถูกวางใน in-memory buffer ก่อน จากนั้น flush ไปยัง log files

Two Types of Transactional Logging:

1. Buffered Logging:

(SPEED: FAST, DURABILITY: GOOD) Transactions ถูกบันทึกลง in-memory log buffer ก่อน เมื่อ buffer เต็ม จะถูก flush ไปยัง disk ใน background กระบวนการนี้เร็วมาก (5000 TPS หรือมากกว่า) มีโอกาสเล็กน้อยที่ transactions อาจสูญหายหาก crash เกิดขึ้นก่อนที่ buffer จะถูก flush ลูกค้าสามารถกำหนดขนาดของ log buffer ได้

2. Durable Commit

(SPEED: SLOW, DURABILITY: EXCELLENT) ทุก transaction จะถูก flush ไปยัง disk ทันที ความเร็วขึ้นอยู่กับความเร็วของ disk device เนื่องจากทุก transaction ถูกบันทึกลงดิสก์ จึงทนทานมาก

ลูกค้าสามารถสลับจาก BUFFERED LOGGING ไปเป็น DURABLE COMMIT ได้ทุกเมื่อ โดยการเรียก SQL function ชื่อ ttDurableCommit(). ลูกค้าสามารถควบคุม durability vs. performance ใน runtime ได้อย่างยืดหยุ่น สิ่งที่ไม่สามารถทำได้กับ conventional RDBMS

Significant Response Time Improvement: In-Memory Database Cache + Oracle Database

Image Source: https://www.oracle.com/technetwork/database/windows/ds-imdb-cache-1-129794.pdf

กราฟข้างต้นแสดง average transaction response time ที่วัดสำหรับแต่ละประเภทของ 7 transaction types

แท่งสีแดงคือ response time ที่ได้เมื่อ data ถูก cached ใน TimesTen IMDB เป็นการปรับปรุงที่ใหญ่โตสำหรับการดำเนินงานของ application database จำได้ว่าส่วนหนึ่งของ response time บน Oracle database เกิดจาก client-server connection และ network roundtrip ซึ่งไม่มีอยู่เมื่อ application เชื่อมต่อโดยตรงกับ TimesTen database ในหน่วยความจำ แอปพลิเคชันยังสามารถเชื่อมต่อกับ TimesTen ผ่าน TCP/IP client/server ได้

Creating a TimesTen Database

Define a DSN

• DataStore attribute: ระบุ directory name ของ checkpoint files ของฐานข้อมูล เช่น DataStore=/data/TTDEMO/TTDEMO-DSN1/TTDEMO-DSN1

• LogDir attribute: ระบุ directory name สำหรับ transaction log files Transaction log มี log records สำหรับแต่ละ database update, commit, และ rollback

• DatabaseCharacterSet attribute: Characterset ที่ข้อมูลถูกจัดเก็บ Logically divided into two separate memory regions

• Database Memory Regions

- Permanent region - PermSize DSN attribute กำหนดขนาดที่จัดสรร - Region จัดเก็บ persistent database elements (เช่น tables, indexes) - Region ถูกเขียนไปยังดิสก์ระหว่าง checkpoint operation
- Temporary region - TempSize DSN attribute กำหนดขนาดที่จัดสรร - Region จัดเก็บ transient data และข้อมูลที่สร้างขึ้นเมื่อรัน statements (temp tables, stored result sets..)

• Database จะถูกสร้างโดยอัตโนมัติเมื่อ instance administrator เชื่อมต่อกับฐานข้อมูล

$ttisql <DSN name>

• Ttisql utility เชื่อมต่อกับ server DSN โดยตรง และ ttIsqlCS utility เชื่อมต่อกับ TimesTen client DSNs

$ttisql connStr "DSN=TTDEMO-DSN1;UID=timesten;pwd=timesten"

• RAM Policy: กำหนดเมื่อฐานข้อมูลถูกโหลดเข้าและปลดออกจากหน่วยความจำ

inUse: ฐานข้อมูลอยู่ในหน่วยความจำหากกำลังใช้งาน (default policy)
always: ฐานข้อมูลถูกเก็บอยู่ในหน่วยความจำตลอดเวลา
manual: ฐานข้อมูลถูกโหลดเข้าและปลดออกจากหน่วยความจำด้วยตนเอง

GitOps สามารถเปิดใช้งาน foundation ที่มีประสิทธิภาพสำหรับการสร้าง Cloud Native applications หลักการสำคัญของ GitOps เน้นประโยชน์ต่อองค์กรดังนี้:

In-Memory Database Cache

Image Source: https://www.oracle.com/database/technologies/timesten-cache.html

• Cache Oracle database tables ใน application-tier

  1. Cache ตารางแต่ละตัวและตารางที่เกี่ยวข้อง
  2. Cache ทุกแถวหรือ subset ของ rows และ columns

• Read-only และ updatable cache database

  1. เข้าถึง cached tables เหมือน regular SQL database tables
  2. Joins/search, insert/update/delete

• Automatic data synchronization

  1. TimesTen ไป Oracle
  2. Oracle ไป TimesTen

Oracle IMDB Cache

• What is a Cache group?

A set of cached tables created in TimesTen database that correspond to tables in Oracle Database

• Read-Only Cache Group

Read Operations ทำใน TimesTen

Write Operations ถูกส่งผ่านไปยัง Oracle และ auto-refreshed ไปยัง TimesTen

Image Source: https://docs.oracle.com/cd/E18283_01/timesten.112/e14261/cache.htm

Cache Connect ใน Oracle ช่วยให้ผู้ใช้ cache subset ของ Oracle database ของพวกเขาเข้า TimesTen เพื่อให้ response time และ throughput ดีกว่าสำหรับข้อมูลที่เข้าถึงบ่อย

คุณสามารถ cache ตารางเต็มๆ, subset ของ rows, หรือ subset ของ columnsได้ Cache สามารถเป็น read-only หรือ updatable หากข้อมูลถูก update ภายใน TimesTen database updates จะถูก propagate ไปยัง Oracle database ผ่าน synchronous write-through หรือ asynchronous write-through คุณสามารถมี multiple cache instances caching จาก Oracle DB เดียวกัน แต่ละ cache instance สามารถมี cached content ที่แตกต่างกันได้

IMDB Cache Administration & Best Practices

• One time Cache Setup ในทั้ง Oracle และ TimesTen databases (per implementation doc)

• Set Cache Agent Restart Policy: Manual, always, norestart

• Specify AUTOREFRESH interval

  • สร้าง INSERT, UPDATE, และ DELETE triggers บน Oracle table(s) ใน cache group
  • Trigger แทรก row เล็กๆ ลงใน logging table ที่ TimesTen เก็บใน Oracle
  • TimesTen agent สอบถามตารางนี้และ refresh ข้อมูลใน interval ที่คุณระบุ • Data Definition changes ใน Oracle จะต้อง LOAD, UNLOAD, FLUSH, REFRESH CACHE GROUPS

สรุป

TimesTen เป็น In-Memory Relational Database ที่ให้ very low latency และ extremely high throughput สำหรับ SQL operations ในขณะที่ให้ standard relational database functionality ผ่าน standard APIs สามารถ deploy เป็น standalone database หรือเป็น high-performance relational cache สำหรับ Oracle Database

ใช้แท็บ Feedback เพื่อแสดงความคิดเห็นหรือถามคำถาม คุณยังสามารถเริ่มสนทนากับเราได้