كلفة الاتصال بقاعدة البيانات
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
explain why applications reuse connections.
الموضوعات المخطط لها
- Opening a PostgreSQL connection costs a TCP handshake, authentication, optional TLS, and a new server process (PostgreSQL uses one process per connection).
- Each connection uses memory on the server; many idle connections waste it.
- A pool keeps a fixed set of open connections and lends them out per transaction.
- The database does useful work only on as many queries as it has CPU cores and disks; extra connections queue inside it.
تفاصيل المخطط المبدئي
عرض عملي
a diagram: 200 request threads, a pool of 10 connections, one database; requests wait in the pool queue rather than inside the database.
اختبر فهمك
Why not open a new connection per request?
أظهر الإجابة
Setup is slow and each connection costs server memory and a process.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.