Geyser gRPC - सर्वश्रेष्ठ अभ्यास
यह गाइड मजबूत, उत्पादन-तैयार अनुप्रयोगों के निर्माण के लिए आवश्यक पैटर्न को कवर करता है Geyser gRPC. Solana स्ट्रीम SDK समर्थन Geyser gRPC.
शुरू करना
- सरल शुरू करें: जटिल फिल्टर जोड़ने से पहले स्ट्रीमिंग से परिचित होने के लिए स्लॉट सदस्यता के साथ शुरू करें।
- बुद्धिमानी से फिल्टर का प्रयोग करें: केवल बैंडविड्थ को कम करने के लिए आपको क्या करना है?CPUवोट लेनदेन यातायात का ~70% है - उन्हें छोड़ दें यदि आपको उनकी आवश्यकता नहीं है।
rust
SubscribeRequestFilterTransactions {
vote: Some(false), // Exclude ~70% vote txs
failed: Some(false), // Exclude failed txs
..Default::default()
}SubscribeRequestFilterTransactions {
vote: Some(false), // Exclude ~70% vote txs
failed: Some(false), // Exclude failed txs
..Default::default()
}कनेक्शन प्रबंधन
- स्वचालित पुनर्संयोजन: नेटवर्क के मुद्दों की उम्मीद; एक्सोनेंशियल बैकऑफ के साथ फिर से कनेक्ट करें।
- पिंग / पोंग हैंडलिंग: Yellowstone gRPC सर्वर पिंग भेजते हैं। हमेशा पोंग के साथ जवाब दें या सर्वर कनेक्शन को बंद कर सकता है (~30s डिस्कनेक्ट का आम कारण)।
rust
if matches!(update.update_oneof, Some(UpdateOneof::Ping(_))) {
subscribe_tx.send(SubscribeRequest {
ping: Some(SubscribeRequestPing { id: 1 }),
..Default::default()
}).await?;
}if matches!(update.update_oneof, Some(UpdateOneof::Ping(_))) {
subscribe_tx.send(SubscribeRequest {
ping: Some(SubscribeRequestPing { id: 1 }),
..Default::default()
}).await?;
}- गैप वसूली: उपयोग
from_slotडेटा हानि से बचने के लिए फिर से कनेक्ट करने के बाद (डुप्लिकेट स्वीकार्य हैं)।
rust
subscribe_request.from_slot = if tracked_slot > 0 {
Some(tracked_slot) // Optionally subtract a small buffer to dodge reorgs
} else {
None
};subscribe_request.from_slot = if tracked_slot > 0 {
Some(tracked_slot) // Optionally subtract a small buffer to dodge reorgs
} else {
None
};वास्तुकला पैटर्न
- व्यापार तर्क से नेटवर्क IO को अलग करने और बैकप्रेस जोड़ने के लिए चैनलों के साथ अलग-अलग प्रवेश और प्रसंस्करण।
rust
let (tx, rx) = mpsc::channel::<SubscribeUpdate>(10_000);
// ingress task reads stream and tx.send(...)
// processing task consumes rx and does business logiclet (tx, rx) = mpsc::channel::<SubscribeUpdate>(10_000);
// ingress task reads stream and tx.send(...)
// processing task consumes rx and does business logic- बाध्य चैनलों का उपयोग करें: प्रसंस्करण गति और डेटा-हानि सहिष्णुता (छोटे = कम स्मृति, अधिक बूंदें); बड़ा = अधिक स्मृति, कम बूंदें) के आधार पर क्षमता चुनें।
प्रदर्शन और लचीलापन
- जब थ्रेसहोल्ड से अधिक हो जाता है तो मॉनिटर प्रोसेसिंग विलंबता और लॉग।
- बैच लिखते हैं; बैच आकार या अंतराल पर फ्लश।
- बाहरी कॉल के लिए async IO का उपयोग करें; कार्यकर्ता कार्यों / थ्रेड्स के लिए भारी शुल्क का बोझ।
- आवंटन को कम करने के लिए सदस्यता अनुरोध का पुन: उपयोग करें।
त्रुटि हैंडलिंग
- त्रुटि प्रकार (स्ट्रीम बनाम प्रोसेसिंग बनाम चैनल) को अलग करें।
- फिर से कनेक्ट करने पर एक्सपोनेंशियल बैकऑफ (छोटे शुरू, एक उचित अधिकतम पर टोपी)।
- लॉग/मीट्रिक ने धीमी-उपभोक्ता स्थितियों को ट्रैक करने के लिए अद्यतन छोड़ दिया।
डेटा प्रबंधन
- उपयोग करते समय डुप्लिकेट को संभालना
from_slot(समय पर जमा कैश या डीबी बाधाएं)। - प्रति उपयोग के मामले में प्रतिबद्धता चुनें:
- संसाधित: सबसे तेजी से डैशबोर्ड, वापस रोल कर सकते हैं
- पुष्टि की: अधिकांश ऐप्स / इंडेक्सर्स के लिए अच्छा डिफ़ॉल्ट
- अंतिम रूप दिया गया: जब पूर्ण निश्चितता की आवश्यकता होती है
गतिशील सदस्यता
बिना किसी संयोजन के रनटाइम (हॉट-स्वैप फिल्टर, विस्तार कवरेज) पर सदस्यता अद्यतन करने के लिए द्विदिशात्मक स्ट्रीम का उपयोग करें।
उत्पादन चेकलिस्ट
- A cheered reconnection of a cheered backoff.
- The estimation of the suffering of the suffering of the suffering.
from_slot - A option of the option of a ping/pong handle (void 30s डिस्कनेक्ट)
- ✅ बाध्य चैनलों / बैकप्रेस के साथ अलग-अलग प्रवेश और प्रसंस्करण
- A gram (a s) in the gram (a s) in the gram (a s) in the gram (a s) in the gram (a s) in the gram (a s) in the gram (a s) in the gram (a s) in the gram (a s) in the gram (a s) in the gram (a s) in the gram (a s) in the gram (a ) in the gram (a ) in the gram (a ) in the gram (a ) in the gram (a ) in the gram (a gram (a ) in the gram (a gram (a ) in the ) in the ) in the gram (a ) in the gram (a gram (a ) in the ) in the gram (a ) in the gram (a gram (a ) in the gram (a ) in the gram (a ) in the gram (a ) in the ) in the gram (
- The process of latency track
- The opposing of the opposing of the opposing of the opposing of the posing of the posing of the posing of the posing of the posing of the posing of the posing of the posing of the posing of the posing of the posing.
- A बैच लिखते हैं (यदि जारी रखा गया है)
- The estifference of the suffering and the suffering of the suffering.
अतिरिक्त संसाधन
- Solana स्ट्रीम SDK (SV)Geyser gRPC समर्थन: https://github.com/ValidatorsDAO/solana-stream