API
🦠 API Architecture
SOAP
A protocol for exchanging structured information in web services. It uses XML for message formatting and relies on HTTP, SMTP, or other transport protocols. Known for its strict standards and strong typing.
RESTful
An architectural style for designing networked applications. Uses standard HTTP methods (GET, POST, PUT, DELETE) for communication and relies on stateless, client-server communication. Often uses JSON for data representation.
GraphQL
A query language and runtime for APIs that allows clients to request only the data they need. Provides a more flexible and efficient alternative to traditional REST APIs by enabling clients to define the structure of the response.
gRPC
An open-source framework developed by Google that uses HTTP/2 for transport and Protocol Buffers for serialization. Enables efficient communication between services with features like bidirectional streaming and multiplexing.
WebSocket
A communication protocol that provides full-duplex communication channels over a single, long-lived connection. Often used for real-time applications where low-latency communication is crucial.
Webhook
A mechanism that allows one system to notify another system about events. Instead of a system polling for updates, the webhook model involves the target system sending HTTP requests to a specified callback URL when an event occurs.
MQTT
A lightweight, open, and efficient messaging protocol designed for low-bandwidth, high-latency, or unreliable networks. Commonly used in IoT (Internet of Things) scenarios.
OData
A standard protocol for building and consuming RESTful APIs. Aims to simplify data sharing between applications and supports CRUD (Create, Read, Update, Delete) operations.
JSON-RPC
A remote procedure call (RPC) protocol encoded in JSON. Allows for the execution of functions on a remote server and is a lightweight alternative to XML-RPC.
XML-RPC
A remote procedure call (RPC) protocol that uses XML to encode messages. Enables the execution of functions on a remote server and is a predecessor to JSON-RPC.
SOAP : เหมาะกับ Enterprise
RESTful : เหมาะกับ Web หรือ Mobile Server
GraphQL : ลด Network Load
gRPC : สำหรับ Microservice คุยกัน
Websocket : สำหรับ Client กับ Server คุยกัน สื่อสารแบบสองทาง
Webhook : แจ้งเตือนเมื่อมีเหตุการณ์
MQTT : สำหรับ IoT หรือเครือข่ายที่ไม่เสถียร
OData : สำหรับการแชร์ข้อมูลใน RESTful APIs
JSON-RPC : การเรียกใช้ฟังก์ชันระยะไกลแบบ JSON
XML-RPC : การเรียกใช้ฟังก์ชันระยะไกลแบบ XML
🦧 API Request Method
GET
Retrieve data from a specified resource.
POST
Submit data to be processed to a specified resource.
PUT
Update a resource or create it if it doesn't exist.
PATCH
Partially update a resource.
DELETE
Delete a specified resource.
OPTIONS
Get information about the communication options for a resource.
HEAD
Retrieve headers of a resource without the body.
🦑 API Health Check
HTTP Status Codes
Examines the HTTP status code returned by the API to determine if it's functioning correctly.
Heartbeat Endpoints
Dedicated endpoints designed to return a simple response confirming that the API is operational.
Ping Endpoints
Simple routes that respond with minimal data to serve as a lightweight health check.
Response Time Monitoring
Monitors the response time of API requests as an indirect measure of API health.
Circuit Breakers
Mechanisms that temporarily block access to the API if the failure rate exceeds a threshold.
Load Balancer Health Checks
Load balancers perform regular health checks on each API instance and route traffic accordingly.
Synthetic Transactions
Automated tests that simulate user interactions with the API to ensure its functionality.
Third-party Monitoring
Services like Pingdom, New Relic, and others provide tools for API health checks and monitoring.
Logging and Error Monitoring
Monitoring logs and tracking errors can help identify potential issues with the API's functionality.
Distributed Tracing
Tracing systems like Jaeger or Zipkin trace API requests across services to identify bottlenecks.
HTTP Status Codes : ตรวจสอบสถานะ HTTP ที่ API ส่งกลับมา เพื่อดูว่า API ยังทำงานปกติหรือไม่
Heartbeat Endpoints : ตรวจสอบการตอบกลับแบบง่ายๆ เพื่อยืนยันว่า API ยังทำงานอยู่
Ping Endpoints : เส้นทางง่ายๆ ที่ตอบกลับด้วยข้อมูลน้อยที่สุด เพื่อใช้ในการตรวจสอบสุขภาพของ API
Response Time Monitoring : ตรวจสอบเวลาการตอบสนองของการเรียกใช้ API
Circuit Breakers : ปิดกั้นการเข้าถึง API ชั่วคราวหากอัตราการล้มเหลวเกินเกณฑ์ที่กำหนดไว้
Load Balancer Health Checks : ตัวบาลานซ์โหลดจะทำการตรวจสอบสุขภาพของแต่ละ API instance อย่างสม่ำเสมอ และกำหนดเส้นทางของการจราจรตามนั้น
Synthetic Transactions : การทดสอบอัตโนมัติที่จำลองการโต้ตอบของผู้ใช้กับ API
Third-party Monitoring : บริการจากภายนอก สำหรับการตรวจสอบและการเฝ้าติดตาม
Logging and Error Monitoring : การตรวจสอบบันทึกและการติดตามข้อผิดพลาด
Distributed Tracing : ระบบการติดตามเช่น Jaeger หรือ Zipkin จะติดตามการเรียกใช้ API ข้ามบริการเพื่อตรวจหาคอขวด
Last updated