# gRPC (Go) > Protocol Buffers, บริการ gRPC, streaming, interceptor, การจัดการข้อผิดพลาด, metadata - 22 คำถามสัมภาษณ์ - Mid-Level - [คำถามสัมภาษณ์: Go](https://sharpskill.dev/th/technologies/go/interview-questions.md) ## 1. gRPC คืออะไร? **คำตอบ** gRPC เป็น framework RPC (Remote Procedure Call) แบบโอเพนซอร์สที่พัฒนาโดย Google ซึ่งใช้ HTTP/2 เป็นโปรโตคอลการรับส่งข้อมูลและ Protocol Buffers เป็นรูปแบบ serialization เริ่มต้น ต่างจาก REST ที่ใช้ JSON และ HTTP/1.1 gRPC ให้ประสิทธิภาพที่ดีกว่าด้วยรูปแบบไบนารีของ Protocol Buffers และฟีเจอร์ขั้นสูงของ HTTP/2 (multiplexing, การบีบอัด header, server push) gRPC ถูกใช้อย่างแพร่หลายในการสื่อสารระหว่าง microservice เพราะรองรับ streaming แบบสองทิศทาง การสร้างโค้ด client/server และการใช้ type ที่เข้มงวดได้แบบเนทีฟ ## 2. บทบาทหลักของ Protocol Buffers ใน gRPC คืออะไร? **คำตอบ** Protocol Buffers (protobuf) คือภาษาสำหรับนิยามอินเทอร์เฟซ (IDL) และรูปแบบ serialization แบบไบนารีที่ใช้เป็นค่าเริ่มต้นใน gRPC โดยช่วยให้กำหนดโครงสร้างของ message และบริการในไฟล์ .proto ซึ่งจะถูกคอมไพล์เพื่อสร้างโค้ด client และ server โดยอัตโนมัติในหลายภาษา รูปแบบไบนารีของ protobuf กระชับกว่า JSON ถึง 3 ถึง 10 เท่า และให้ประสิทธิภาพการ serialization/deserialization ที่เหนือกว่าอย่างเห็นได้ชัด (เร็วกว่าถึง 20 เท่า) สิ่งนี้ทำให้ gRPC เหมาะอย่างยิ่งสำหรับการสื่อสารความถี่สูงระหว่าง microservice ## 3. ความแตกต่างระหว่างการเรียก gRPC แบบ Unary กับการเรียกแบบ Server Streaming คืออะไร? **คำตอบ** การเรียกแบบ Unary เป็นการเรียก gRPC ที่ง่ายที่สุด: ไคลเอนต์ส่งคำขอเดียวและได้รับการตอบกลับเดียว คล้ายกับคำขอ HTTP REST แบบดั้งเดิม การเรียกแบบ Server Streaming ช่วยให้ไคลเอนต์ส่งคำขอเดียวแต่ได้รับสตรีม (stream) ของการตอบกลับหลายรายการจากเซิร์ฟเวอร์ ตัวอย่างเช่น API การแจ้งเตือนสามารถใช้ Server Streaming เพื่อส่งการอัปเดตหลายรายการไปยังไคลเอนต์โดยไคลเอนต์ไม่ต้อง polling สิ่งนี้ลด latency และภาระเครือข่ายเมื่อเทียบกับการเรียก Unary ซ้ำ ๆ ## มีอีก 19 คำถาม - package Go ใดที่ใช้ในการสร้างเซิร์ฟเวอร์ gRPC? - จะนิยามบริการ gRPC ในไฟล์ .proto ได้อย่างไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Go อื่นๆ - [พื้นฐาน Go](https://sharpskill.dev/th/technologies/go/interview-questions/go-basics.md): 25 คำถาม, Junior - [โครงสร้างข้อมูล Go](https://sharpskill.dev/th/technologies/go/interview-questions/go-data-structures.md): 20 คำถาม, Junior - [อินเทอร์เฟซใน Go](https://sharpskill.dev/th/technologies/go/interview-questions/go-interfaces.md): 18 คำถาม, Junior - [การจัดการข้อผิดพลาด](https://sharpskill.dev/th/technologies/go/interview-questions/error-handling.md): 20 คำถาม, Junior - [พื้นฐาน Goroutine](https://sharpskill.dev/th/technologies/go/interview-questions/goroutines-basics.md): 20 คำถาม, Junior - [Channels](https://sharpskill.dev/th/technologies/go/interview-questions/channels.md): 22 คำถาม, Junior - [Go Modules](https://sharpskill.dev/th/technologies/go/interview-questions/go-modules.md): 18 คำถาม, Mid-Level - [เซิร์ฟเวอร์ HTTP](https://sharpskill.dev/th/technologies/go/interview-questions/http-server.md): 24 คำถาม, Mid-Level - [ไคลเอนต์ HTTP](https://sharpskill.dev/th/technologies/go/interview-questions/http-client.md): 18 คำถาม, Mid-Level - [การเข้ารหัส JSON](https://sharpskill.dev/th/technologies/go/interview-questions/json-encoding.md): 20 คำถาม, Mid-Level - [Database/SQL](https://sharpskill.dev/th/technologies/go/interview-questions/database-sql.md): 22 คำถาม, Mid-Level - [แพ็กเกจ context](https://sharpskill.dev/th/technologies/go/interview-questions/context-package.md): 20 คำถาม, Mid-Level - [Testing](https://sharpskill.dev/th/technologies/go/interview-questions/testing.md): 22 คำถาม, Mid-Level - [รูปแบบ Concurrency](https://sharpskill.dev/th/technologies/go/interview-questions/concurrency-patterns.md): 24 คำถาม, Mid-Level - [ไพรมิทีฟการซิงโครไนซ์](https://sharpskill.dev/th/technologies/go/interview-questions/sync-primitives.md): 22 คำถาม, Mid-Level - [เฟรมเวิร์กเว็บ Go](https://sharpskill.dev/th/technologies/go/interview-questions/go-web-frameworks.md): 20 คำถาม, Mid-Level - [การออกแบบ REST API](https://sharpskill.dev/th/technologies/go/interview-questions/rest-api-design.md): 20 คำถาม, Mid-Level - [Reflection](https://sharpskill.dev/th/technologies/go/interview-questions/reflection.md): 20 คำถาม, Senior - [การจัดการหน่วยความจำ](https://sharpskill.dev/th/technologies/go/interview-questions/memory-management.md): 24 คำถาม, Senior - [การเพิ่มประสิทธิภาพการทำงาน](https://sharpskill.dev/th/technologies/go/interview-questions/performance-optimization.md): 22 คำถาม, Senior - [Generics](https://sharpskill.dev/th/technologies/go/interview-questions/generics.md): 20 คำถาม, Senior - [Go Design Patterns](https://sharpskill.dev/th/technologies/go/interview-questions/design-patterns.md): 24 คำถาม, Senior - [Microservices](https://sharpskill.dev/th/technologies/go/interview-questions/microservices.md): 24 คำถาม, Senior - [ความปลอดภัยและการยืนยันตัวตน](https://sharpskill.dev/th/technologies/go/interview-questions/security-authentication.md): 24 คำถาม, Senior - [Docker & Containerization](https://sharpskill.dev/th/technologies/go/interview-questions/docker-containerization.md): 20 คำถาม, Senior - [Kubernetes Basics](https://sharpskill.dev/th/technologies/go/interview-questions/kubernetes-basics.md): 22 คำถาม, Senior - [Go ขั้นสูง](https://sharpskill.dev/th/technologies/go/interview-questions/advanced-go.md): 20 คำถาม, Senior - [การพัฒนา CLI](https://sharpskill.dev/th/technologies/go/interview-questions/cli-development.md): 20 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/go/interview-questions/grpc