Skip to main content

· 3 min read
tony

Issue with slot34 (Dragon and the Fortune Pearl)

  • Currently, Slot34 saves a matrix after each spin to help choose the right payout. This is done by the AWP engine. However, the matrices are not diverse, making it hard to choose the right payout.

  • With 12 symbols and 15 cells, Slot34 can theoretically produce a trillion combinations. However, generating all of these would take over a century, making it impractical to store all results.

Solution

  • Heuristic technique → Pattern generator

Pattern generator

  1. Generate 1 million matrices and calculate their payouts.

  2. Create a pattern from each matrix and map it to its payout.

    • For example: "4101": ["AW0BDSW0CEWW00D", "W0WWDS0WBEA0WCF"].

    • Explain:

      • The pattern takes the form payout → [Patterns of matrices].

      • W and S stand for wild and scatter.

      • Numbers stand for symbol ids, which indicate the winning symbol.

      • Characters stand for any symbol.

  3. Construct a decision tree using the calculated payouts.

  4. Load each pattern and identify the optimal one based on:

    • Payout

    • Filled matrix

Test & Report

Payout combined

Payout rangeCountPatterns
0 - 1001499313817
100 - 2001498105038
200 - 400205229198
400 - 6004591732
≥ 60047142

Payout range

AWP + payout combined

// awp setting

{Min: 0, Max: 23000, MinHitRate: 0.25, MaxHitRate: 0.85, RtpAdjustment: 0.01, MaxPayoutMultiplier: 300, Weightages: []float64{35, 25, 20, 10, 10}}

payout_rangecountunique_matrix% (unique / count)
0.00 - 0.0052059140626378.04
0.00 - 1.0041267936879189.37
1.00 - 5.00385383695895.90
5.00 - 11.00135221314197.18
11.00 - 20.006679659998.80
20.00 - 33.503442340198.81
33.50 - 53.752169212898.11
53.75 - 84.121294126197.45
84.12 - 129.6958857597.79
129.69 - 198.0336935295.39
198.03 - 300.0012912395.35

Payout range

Resource

· 5 min read
Tada

Here are books that I write them under our career ladders and it based on my personal references which I believes with fit for you, but you can read them even if you're not reach that milestones, you can read it whenever it catch your intention.

note

This library will keep update time by time, content of those books based on our technical stack and our engineer culture. Feel free to contribute books that really help you in our career.

Individual Contributor

Associate Software Engineer

As in early of in a career, I think we should by a strong foundation on how be a good engineer, write a good code

Book Info

Dive Into DESIGN PATTERNS

Link to buy: refactoring.guru


In my early of my career, Java is the second language that I worked on my job, and as a developer came from Java World & one of the questions I always ask when start write a program with Go Lang is "How to use Dependency Injection in Go Lang?" & This book completed answering my question. Beside of that, it provides much useful knowledge to "Never Stop Aiming for Better." I love the format of this book; each chapter always ends with some question to remind you, do you understand what the author wants to show you in this chapter. And this book shows how to apply DI in many ways based on design principles like SOLID.

Book Info

Hands-On Dependency Injection in Go

Link to buy: Amazon


This is the book I wish I could have read early in my career as a software developer.

Book Info

The Software Engineer's Guidebook: Navigating senior, tech lead, and staff engineer positions at tech companies and startups.

Link to buy: Amazon


Software Engineer

After 1-2 years as a new engineer, time to setup a good philosophy to be continue in that journey This book will be a good guideline

Book Info

The Pragmatic Programmer: From Journeyman to Master

Link to buy: Amazon


In this milestone of your journey you started to take care a larger part, your scope of work is extended And you started serious about system design, how to know it's good design or bad design This book not only practice for interview, but actually you can learn a lot from the way to build a good system

Book Info

System Design Interview – An insider's guide

Link to buy: Amazon

System Design Interview – An Insider's Guide: Volume 2

Link to buy: Amazon


Senior Software Engineer

“This book belongs on the shelf of every thoughtful software developer.”

—Kent Beck

Book Info

Domain-Driven Design: Tackling Complexity in the Heart of Software

Link to buy: Amazon


Staff Software Engineer

This book feels like the missing manual for my whole career. It’s amazingly reassuring to see the ambiguity of the role laid out in print, along with great specific guidance on time management, consensus building, etc. I’m going to cite this a lot.

​—​Titus Winters, principal engineer, Google, and coauthor of Software Engineering at Google

Book Info

The Staff Engineer's Path

Link to buy: Amazon


Manager

Lead Software Engineer

The Manager’s Path gives the big picture perspective on what a career in engineering management looks like. Camille provides very tactical advice for each career stage. And because engineering managers have a great responsibility to their reports to learn how to manage well, you should read this book and learn how it is done. This book is a practical guide to understanding and pursuing a career in Engineering Management.

​—Liz Crawford, Entrepreneur in Residence, Genacast Ventures; former CTO, Birchbox

Book Info

The Manager's Path: A Guide for Tech Leaders Navigating Growth and Change

Link to buy: Amazon


Software Engineer Manager

As managers around the world grapple with a complex economic environment, this book provides a rich roadmap for extracting the full value of the people in their organizations. This book is a great investment for anyone managing a business in the innovation marketplace.

—Jeff Henley, chairman of the board, Oracle Corporation

Book Info

Multipliers: How the Best Leaders Make Everyone Smarter

Link to buy: Amazon


Senior Software Engineer Manager

out·li·er -,l()r\ noun 1: something that is situated away from or classed differently from a main or related body 2: a statistical observation that is markedly different in value from the others of the sample

Book Info

Outliers: The Story of Success

Link to buy: Amazon


Most business books give you the same old advice: Write a business plan, study the competition, seek investors, yadda yadda. If you're looking for a book like that, put this one back on the shelf.

Read it and you'll know why plans are actually harmful, why you don't need outside investors, and why you're better off ignoring the competition. The truth is, you need less than you think. You don't need to be a workaholic. You don't need to staff up. You don't need to waste time on paperwork or meetings. You don't even need an office. Those are all just excuses

Book Info

Rework

Link to buy: Amazon

· 3 min read
Quang Nhat Nguyen

Multiple Languages and Multiple Orientations:

Wait and implement on game client's design but our expected solution will be loaded dynamic resource from server when user access into game

Multiple Currencies:

After consulting various solutions online and researching products from major game providers, the best solution is using a currency within a channel or gaming session and require players or tenants to choose in advance before entering the game.

Technical Solution

Adding a layer currency on all settings about bet level, jackpot, pay rate for our games. So, we need to update some libraries such as mypot, myrank, myhistory for supporting storing and listing data for each currency.

multiple_currencies_setting

Accompanying this solution, there will be implications on our games:

Case 1: Implement multiple currencies by updating the logic in our existing games

Slot games:

Core-logic game is not related to currency, the game's feature doesn't require realtime and just only an user play game so we easily apply the currency for game session.

Table games:

The game's feature require realtime, currency that is used in each channel must be unique because each currency has different chip, rate, jackpot and leaderboard. However current design + logic implementation don't allow to run multiple channels

Recommended solution:

  • Support multiple channel and scale out service (each channel run independently on an instance)
  • Logic directs user into channel

Card games:

Have available support for multiple channel so we can apply currency for each channel, but the difficulty is that must implement more multiple lobbies.

Recommended solution:

  • Support multiple lobbies for each currency

Case 2: Consider cloning server to single-instance support for a single currency.

In this case, there's no need for updates to the existing games, which simplifies the game implementation. There's no need to concern ourselves with currencies.

However, to ensure the user join the correct instance corresponding to their currency of choice, it's essential to have a system in place that directs users to instances matching their respective currencies.

Statistic & Report

We can implement statistics and reports for each currency. In cases where broader statistics are required, we can convert all currencies to 'VND' for uniformity.

Note: Some tenants lack currency management for their users. All they can do is deposit the currency they support, and they rely on us to convert it for them to participate in games. Consequently, on our end, we must resolve this problem to accommodate a wider range of tenants.

· 3 min read
tony

Version

What is gRPC stream?

A gRPC stream refers to a communication channel that allows bidirectional data flow between a client and a server in real-time. It's one of the key features of gRPC and is used for various purposes, including real-time updates, event-driven communication, and efficient data streaming

We can follow the older post in here: gRPC stream vs Websocket

What is Cocos Creator?

Cocos Creator is both an efficient, lightweight, free and open source cross-platform 2D & 3D graphics engine and a real-time interactive 2D & 3D digital content creation platform. With many advantages such as High Performance, Low Power Consumption, Streaming Loading and Cross-Platform Publishing, we can use it to create projects in fields such as Games, Cars, XR, MetaVerse etc.

Problem

We are having issues using gRPC Stream in our project because it is not supported by Cocos Creator; let's take a deeper look at why this is the case.

Testing gRPC stream with Cocos Creator

Crearte streaming_test.proto

service StreamingTest {
rpc BiDirectional(stream Message) returns (stream Message);
rpc SeverStreaming(SeverStreamingRequest) returns (stream Message);
rpc ClientStreaming(stream Message) returns (ClientStreamReply);
}

message Message {
string id = 1;
bytes metadata = 2;
google.protobuf.Timestamp created_at = 3;
}

message SeverStreamingRequest {}

message ClientStreamReply {}

grpc/grpc-web

  1. Set up gRPC-web
  1. Generate
$ protoc -I=$DIR streaming_test.proto \
--js_out=import_style=commonjs:$OUT_DIR \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:$OUT_DIR

But... Client-side and Bi-directional streaming is not currently supported

Alt Text

improbable-eng/grpc-web

gRPC Web implementation for Golang and TypeScript, a custom lib forked from grpc/grpc-web

It sill not working with Cocos Creator 😞

Root cause

The issue we're facing pertains to using the "connect" method in Cocos, which is challenging due to Cocos using an older JavaScript engine that doesn't support newer APIs. grpc-web stream specifically require the Fetch API for out project.

We attempted to implement the Fetch API through XMLHttpRequest using a polyfill. While we were successful in making unary (single) method calls, we encountered difficulties with streaming. This is because XMLHttpRequest doesn't support reading a partial response body (chunk) - we must wait for the request to complete before accessing the entire body.

To fully address this issue, we would need to dive deeper into native code and create a custom implementation of the Fetch API that supports streaming. Keep in mind that this is our experience with Android, and we would need to separately implement and test for iOS.

It's also worth noting that the grpc-web library faces a similar limitation as it uses XMLHttpRequest, it is unable to perform asynchronous operations, which could be the reason it doesn't fully support streaming.

KaKa

Therefore... we use websocket instead 😁

Alt Text

References

· 3 min read
Harry Nguyen
Lyly Nguyen

bot_system

Service

  • 1 MyBot: Library for bot system
    • gRPC
      • Provides an API for controlling the ON/OFF state of the bot.
    • HTTP Internal Setting
      • Offers an API for importing scenarios and group settings, allowing for updates.
    • Scenario + group bot
      • Involves defining specific use cases and interactions for the bot.
      • Designed for use within group chats or channels.
    • Health check
      • Checks the health of the bot system and takes action if issues are detected, such as restarting the bot.
    • Refill Balance
      • Requires operator approval to replenish the bot's balance when requested.
    • Schedule
      • Reads a schedule to execute tasks at specific times, possibly sourced from the Scenario + Group settings.
  • 2 Bot service (xocdia, baucua, tala): Extend from mybot to implement logic and deploys service for each game, resulting in different pods for each game.
    • Logic Game
      • Contains the logic for running games
  • 3 Issue when registration bot
    • Registration Directions
      • From the game:
        • Advantage: Merchant doesn't need to provide a lot of data and implement many steps. They only need to request bot creation.
        • Disadvantage: They must handle history, leaderboards, and jackpots. They need to manage money transfers between the bot and the house, and between the bot and players.
      • From the Merchant
        • Advantage: The game doesn't have to worry about bots because the gateway treats bots as humans.
        • Disadvantage: The gateway must handle financial data, report to the bots as if they were humans.
          • They must take responsibility for initializing and depositing money for bots (a risk for merchants).
          • In cases where the game operator does not have a gaming gateway, the game will not have bots to play.
    • Who will approve balance refills?
      • Bots will send requests to the Back Office, and the Back Office will approve and deposit money for bots.
    • Virtual Money from a game
      • Depending on the type of game, this part is implemented differently.
      • For slots and table games, virtual money can be used. However, transactions need to be saved for statistics and leaderboard display.
      • For card games, TXMN (money transfer) occurs between users and bots. Bots are virtual money, but the money must be obtained from the house. If someone bets, but the leaderboard is empty, who will fill it?
    • Current Standalone System
      • If there are two merchants on the same game server, the money flow is shared among the merchants on one game.
      • For example, if Merchant A wants to initialize a bot, and Merchant B does not, if the bot is requested to be initialized for Merchant A, it will disadvantage Merchant A if B does not release the bot because the bot's money initialized by Merchant A will be lost.
      • The game must have a mechanism to differentiate the money flow according to each company key.
    • Conclusion for all issue above
      • It is possible to create users from the game's side. Nautilus will initialize the service for registration and differentiate bots.
      • Nautilus will create a company key for bots.
      • Merchants integrate and agree to initialize the amount of money for bots and agree to transfer money to bots.

Conclusion

  • The system is designed to be easy to deploy and integrate with new games.

· 3 min read
Harry Nguyen
Lyly Nguyen
  • There are support libraries for games
    • mymes -> Send message
    • myrank -> Top player info
    • my history -> game history
    • my pot -> game jackpot
  • EDK:
    • WS Handler
    • Authentication
    • Payment
    • Agones
    • Merchant management
    • User management
  • Can run standalone service

Points Of Satisfaction

  • Have HTLM to call to cheat . Easy for QC test
  • The features already have libraries to address common features
  • EDK
    • Good for integration
  • Game setting: enough to build the setting & allow http.

Points Of Dissatisfaction

  • There is no documentation page for aggregating documentation
    • Getting started: Introduction for beginners in game development
    • Functions of libraries
    • Diagram illustrating the structure of a standalone game
    • Integration with 'gateway' or something similar
  • Game cloning speed
    • There is no standard document for quickly cloning a game
      • How to design proto?
      • How to implement logic?
  • Logic game
    • There aren't flow chart to describe the implementation flow (Session, channel, message, user-actor model.)
    • When looking at it for the first time, you don't know where to start
  • UnitTest
    • There is no local test for testing the game -> So the deployment must ensure the logic of testing

Points for Improvement

  • Add libraries into mykit to Init project

    • Include common code libraries to avoid having to copy (mymes, myrank ..)
  • Create multiple channels in a service

    • Why not create multiple channels -> Users can play on various different channels for one game
    • Reason:
      • Currently, users are opening multiple tables and can place multiple bets in one game -> I have observed that users often do this
      • Currently, Long Hổ uses library protoactor.NewActorSystem to support multiple channels -> actor_system -> channel_actor -> user_actor => We should use this advantages
  • Define proto according to a specific template, with clear divisions

    • game.proto: Defines the API for a component or service. This typically specifies the remote procedure calls (RPCs) and message types used for communication.
    • game_model.proto: Defines the object models or data structures used in your application or system. These models are often used to represent data in a structured format.
    • game_config.proto: Defines the configuration settings for your application. These settings can be used to customize the behavior or parameters of your application.
    • game_code.proto: Defines error codes and possibly error messages that can be used in your application to handle and report errors.
    • game_butler.proto: Defines APIs specifically for operators or administrators to manage or control aspects of the system.
  • UnitTest

    • Auto Team will build standard test to call and test local witch connect to stg.
  • Logic game

    • There should be a flow chart to describe the implementation flow

Conclusion

  • We need to improve the structure to shorten the game development time for developers. Allocate time for enhancing logic and performance.

Reference

· 4 min read
tony

Comparison feature between game providers

Soft GamingsWorld EntertainmentPragmatic PlayPG Soft
Affiliate SystemAn individual or business signs up for the affiliate program offered by the gambling platform. They become an affiliate partner.
Affiliate partner can
- Register
- Set commission, campaigns, postbacks, etc
- Get reporting and payments
- ...
Must contact platformMust contact platformMust contact platform
Authentication- Use hmac with SHA-256 using secret key shared- Use both token, operator_id and app_secret- Use hash with MD5 using all parameters and secret key shared- Use signature with HMAC-SHA25 using a string includes {host}{x-content-sha256}{x-date}
Wallet Type Support- Seamless Wallet (One Wallet)- Seamless Wallet- Seamless Wallet
- Balance Transfer
- Seamless Wallet
- Balance Transfer
Games- List games
- Allow edit game settings
- Add/edit group or category of games
- List games by category or type- Allow list games only- List games
- Create free games
Game Settings- Allow- Allow- Allow- Allow
Bet History- Allow- Allow- Allow- Allow
Player Management- Allow-- Allow- Allow
Loyalty- Levels
- Users
- Logs
- Transactions
- Events list
- Store items
- ...
---
Bonus Games- Allow (include loyalty)-- Allow- Allow
Tournaments- Allow-- Allow- Allow
Achievements- Allow---
Promotions- Allow---
Custom Error Response- Yes- Yes- Yes- Yes
Languages- Support more 30+ languages- 6 languages- Support player language in ISO 639-1 standard- Support more 90+ languages
Currency- Support more 50+ currencies- Support 17 currencies with various ratios- Player's ISO3 currency code- Support more 100+ currencies code include fiat currencies with various ratios, crypto currencies
Support Multiple Platforms- Allow- Allow- Allow- Allow
IP Restriction---- Allow
Game Orientation----

Conclusion

In this comprehensive comparison of game providers, including Soft Gamings, World Entertainment, Pragmatic Play, and PG Soft, we've evaluated key features and strengths in the gaming industry. As we set our sights on becoming a successful game provider, we recognize the significance of certain "must-have" features and the potential for innovation in this highly competitive field.

Feature suggestions

  1. Advanced Analytics (Must-Have): Providing operators with comprehensive game statistics and insights.

  2. Multi-Language Support (Must-Have): Global accessibility through support for multiple languages.

  3. Multi-Currency Support (Must-Have): Allows players to deposit, play, and withdraw funds in their local currencies

  4. Multi-Platform Support (Must-Have): Ensure that your platform seamlessly supports multiple devices and operating systems, offering a consistent user experience across various platforms

  5. Customization Options (Must-Have): Allowing players to personalize their gaming experience.

  6. Progressive (Mega) Jackpot (Should-Have): Attracting players seeking significant wins and excitement.

  7. Tournaments and Competitions (Should-Have): Regular events add an element of competition and excitement.

  8. Innovative Game Features (Should-Have): Developing unique features to captivate players

  9. Loyalty Program (Could-Have): Implement a comprehensive loyalty program that includes levels, user rewards, transaction logs, event tracking, and a store for in-game items. Loyalty programs can enhance player retention and engagement.

  10. Multi-Currency Bonus System (Could-Have): Extend the bonus system to support multi-currency bonuses, allowing operators to create promotions and rewards in various currencies to cater to a global audience.

  11. Game Orientation Options (Could-Have): Offer options for game orientation to accommodate different player preferences, including landscape and portrait modes.

References

· 4 min read
Quang Nhat Nguyen

Pocket Games Soft or PG Soft is a mobile game development company based in Valletta, Malta. Founded in 2015, the company has grown into a strong team of 200 employees with offices based in Europe, North America and Asia.

PG Soft offers two different solutions for the casino gaming industry: a complete platform composed of the games and a wallet (i.e. the system that manages the players and their accounts) and, on the other hand, a solution that includes only the games.

In this comparison tailored to this field, we will explore the intricacies of both models, their features, use cases, and considerations to help you make an informed choice for your in-game wallet needs.

Understanding the Wallet Integration Models

Transfer Wallet

The Transfer Wallet is designed for casino games developers and publishers who prioritize secure and efficient transfer of in-game currencies and assets between players. It is characterized by the following key attributes:

  • Security: The Transfer Wallet places a strong emphasis on security, with robust encryption and authentication mechanisms to safeguard in-game assets during transfers. In the world of casino games, where virtual currencies hold real-world value, this security is paramount.

  • Efficiency: It excels at the rapid movement of in-game currencies, making it an ideal choice for scenarios where timely and secure transfers between players are critical, such as in-game trading or peer-to-peer transactions.

  • Customization: The Transfer Wallet offers a high degree of customization, allowing game developers to tailor the wallet's security settings, transaction preferences, and supported in-game currencies to their specific game's requirements.

Workflow:

transfer_model_workflow

Seamless Wallet

The Seamless Wallet focuses on creating a seamless and immersive player experience by integrating in-game wallet functionalities seamlessly into the gameplay. Key features include:

  • Integration with Gameplay: This model seamlessly integrates wallet functionalities into the gameplay itself, allowing players to interact with in-game currencies and assets as an integral part of the gaming experience. It aims to create a frictionless and immersive environment for players.

  • User Experience: In the casino games, player experience is paramount. The Seamless Wallet prioritizes a user-friendly interface, real-time asset tracking, and in-game access to diverse financial transactions and purchases. It aims to simplify in-game financial operations for players.

  • Scalability: The Seamless Wallet can scale with the complexity of games, accommodating an expanding range of in-game currencies, assets, and transactions as the game evolves.

Workflow:

seamless_model_workflow

Use Cases in Casino Games

Let's explore the practical applications of each wallet integration model within games:

Transfer Wallet

  • Player-to-Player Trading: Casino games often involve player-to-player trading of in-game items and currencies. The Transfer Wallet is well-suited for secure and efficient player-to-player transactions.

  • Custom In-Game Economies: For the games with custom in-game economies involving various currencies and assets, the Transfer Wallet is flexibility allows for tailored financial systems and secure transactions.

Seamless Wallet

  • Immersive Gameplay: In casino games where in-game currencies and assets play a central role, the Seamless Wallet enhances the player experience by seamlessly integrating financial interactions into the gameplay itself. Players can earn, spend, and trade in-game assets effortlessly.

  • In-Game Purchases: For the games with microtransactions, virtual goods, or in-game stores, the Seamless Wallet streamlines in-game purchases, making it convenient for players to acquire items, upgrades, and cosmetics without leaving the gaming environment.

Making the Choice in Casino Games

Selecting between Transfer Wallet and Seamless Wallet within the games requires a thorough evaluation of your specific game's requirements. Consider these key factors:

  • Security vs. Immersion: In Casino games, where both security and immersive gameplay are important, assess the need for secure player-to-player transactions against the desire for a seamless and immersive gaming experience.

  • In-Game Economies: Examine the complexity of your game's in-game economies and currencies. If you have custom currencies and a need for secure trading, the Transfer Wallet may be suitable. If your game revolves around in-game assets and player interactions, Seamless Wallet may enhance the overall experience.

  • Player Experience: Player satisfaction is paramount in Casino games. If you prioritize a user-friendly interface and seamless financial interactions within the game, the Seamless Wallet aligns with your player-centric approach.

  • Game Scalability: Consider your game's growth plans. If you anticipate expanding the in-game economy, assets, and transactions, the Seamless Wallet's scalability can accommodate your evolving game.

Conclusion

Both Transfer Wallet and Seamless Wallet offer valuable solutions for managing in-game currencies and assets within Casino games. Your choice should align with your specific game requirements, including security, in-game economy complexity, player experience, and scalability. Make an informed decision that will enhance player engagement, streamline in-game financial operations, and contribute to your success in the vibrant world of Casino games.

Reference

· 4 min read
tony

Which communication protocol is suitable for our project? grpc stream or websocket

Let's research them

What is gRPC stream?

A gRPC stream refers to a communication channel that allows bidirectional data flow between a client and a server in real-time. It's one of the key features of gRPC and is used for various purposes, including real-time updates, event-driven communication, and efficient data streaming

Advantages of gRPC

  • Cross platform: supports multiple programming languages and platforms, making it easy for you to use it in a variety of projects.
  • Strong typing: gRPC uses Protocol Buffers for defining services and methods, which ensures that the client and server share a common understanding of the data being exchanged.
  • Streaming: gRPC supports streaming, which allows for the continuous exchange of data between the client and server, making it ideal for real-time applications.
  • High performance: gRPC uses HTTP/2 and efficient binary encoding formats like Protocol Buffers, which make it faster and more efficient than other RPC frameworks.
  • Scalability: gRPC is designed to be highly scalable, allowing for the easy deployment of micro-services and other distributed systems.

Disadvantages of gRPC

  • Limited browser support: gRPC’s reliance on HTTP/2 means that it may not be compatible with all browsers and platforms.
  • Debugging: Debugging gRPC can be more difficult than debugging other RPC frameworks due to its use of binary encoding formats.
  • Complexity: gRPC can be more complex to set up and use than other RPC frameworks due to its reliance on Protocol Buffers and HTTP/2.
  • Deployment: gRPC may require additional infrastructure and configuration to deploy effectively, especially in large-scale distributed systems.

What is WebSocket?

WebSocket is a protocol that enables real-time, bidirectional communication between a client and a server over a single, long-lived connection. Unlike HTTP, which is a request-response protocol, WebSocket allows for continuous data exchange between the client and serve

Advantages of WebSocket

  • Cross platform: There are numerous libraries and frameworks implementing the WebSocket protocol across all programming languages and development platforms.
  • Built for the web: Browsers natively support the WebSocket API, which is an advantage compared to gRPC.
  • Supports text and binary: You can use any text or binary data format for the data. You could choose a text format to simplify debugging or a compact binary format to maximize efficiency.
  • Bi-directional communication: With WebSocket, both the client and server can send and receive data in real time, allowing for bi-directional communication.

Disadvantages of WebSocket

  • Complexity: WebSocket requires a more complex implementation compared to other communication protocols, which can make it more difficult to set up and maintain.
  • Security: WebSocket is vulnerable to certain types of security attacks, such as cross-site scripting (XSS) and cross-site request forgery (CSRF). However, these can be mitigated with appropriate security measures.
  • Firewalls and proxies: WebSocket can be blocked by some firewalls and proxies, which can limit its usability in certain environments.
  • Limited use cases: WebSocket is primarily designed for real-time web applications and may not be the best choice for other types of applications that do not require low-latency communication.

What are the differences between gRPC stream and WebSocket?

gRPC StreamWebSocket
ProtocolHTTP/2, use the gRPC protocolHTTP/1.1, use WebSocket protocol
Communication TypeClient (request) streaming
Server (response) streaming
Bi-directional streaming
Full-duplex, bidirectional communication
Data formatBinary, uses Protocol Buffers, which is fast and efficient for small to medium-sized messagesText or binary, uses text-based messaging protocol
ScalabilitygRPC can handle large traffic volumes and has built-in load-balancing featuresWebSocket can handle moderate traffic but may require additional load-balancing tools
SecuritygRPC uses Transport Layer Security (TLS) encryption by default and has built-in authentication featuresWebSocket can use TLS encryption but lacks built-in authentication features
Use caseIdeal for micro-services architectures and real-time data streaming applicationsIdeal for real-time data streaming applications and web applications

Conclusion

Whether you should use gRPC stream or WebSockets depends on the specifics of your use case

With the question at the beginning of the article

Which communication protocol is suitable for our project?`

I think gRPC stream is a interesting choice. We used gRPC for client-server and service-to-service communication. So it is really efficiently and flexibility in in microservices architectures

Reference