<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Omar Belghaouti</title>
    <description>The latest articles on DEV Community by Omar Belghaouti (@omdxp).</description>
    <link>https://dev.to/omdxp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F740968%2F6639e4e8-c0e7-4e9d-8f28-34b8664c157b.jpeg</url>
      <title>DEV Community: Omar Belghaouti</title>
      <link>https://dev.to/omdxp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/omdxp"/>
    <language>en</language>
    <item>
      <title>Microservices are bad for some cases…</title>
      <dc:creator>Omar Belghaouti</dc:creator>
      <pubDate>Tue, 27 Sep 2022 16:37:32 +0000</pubDate>
      <link>https://dev.to/omdxp/microservices-are-bad-for-some-cases-1job</link>
      <guid>https://dev.to/omdxp/microservices-are-bad-for-some-cases-1job</guid>
      <description>&lt;p&gt;Microservices are bad (for some cases as well)!&lt;br&gt;
One of the most trickiest things to have when dealing with Microservices is that sometimes there are chances to have problems during the communication between services, maybe one of the services is down at the moment, one solution for that is having some replicas for that service (like having PaaS tools like Kubernetes or Docker Swarm to orchestrate your services).&lt;/p&gt;

&lt;p&gt;Having said that, it may become difficult to manage large amount of services, especially when some services are dependent to other ones.&lt;/p&gt;

&lt;p&gt;One of the hardest things as well is that the testing may become complex over a distributed environment. Sometimes you may create some fake APIs for your testing to unit test your single service, it’s not ideal but it can do the job.&lt;/p&gt;

&lt;p&gt;So keep in mind, not all solutions are the ideal ones, there are always drawbacks and challenges to deal with them. Sometimes your problem can be solved in a Monolithic architecture instead of Microservices, maybe you want vertical scale instead of horizontal scale? It’s always about choosing the path and design your system that suits your problem..&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>monolith</category>
      <category>dokcer</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Hands on gRPC</title>
      <dc:creator>Omar Belghaouti</dc:creator>
      <pubDate>Tue, 27 Sep 2022 16:34:58 +0000</pubDate>
      <link>https://dev.to/omdxp/hands-on-grpc-30fj</link>
      <guid>https://dev.to/omdxp/hands-on-grpc-30fj</guid>
      <description>&lt;p&gt;gRPC is becoming the standard to communicate between microservices. It uses HTTP 2.0 (released in 2015) as its underlying transfer protocol which is more faster and efficient compared to HTTP 1.1 that was released at 1997 and still used in the modern days.&lt;/p&gt;

&lt;p&gt;And with all that it secures the connections by default with SSL/TLS, so not only performance but also security are included.&lt;/p&gt;

&lt;p&gt;Unlike REST APIs which uses json communication which takes a lot of size and latency, it uses what it is called by ProtoBuf (Protocol Buffers) that are way minimal and faster with communications.&lt;/p&gt;

&lt;p&gt;For now, gRPC is used a lot in micro services and mobiles, especially for mobiles because it is faster and the transferred data is minimal and can be delivered in minimal time compared to HTTP 1.1. For web it’s still not there yet but there are some workarounds like making some gateways for that matter.&lt;/p&gt;

&lt;p&gt;Also one of the cool features about gRPC framework is that it is language agnostic, meaning that it works for any language out there, you just need to write a proto file which has a simple syntax and then let the protoc (proto compiler) handle generating the code for the language you want like C++, Go, Java, … etc. All what you need to care about is the implementation for the services.&lt;/p&gt;

&lt;p&gt;There are 4 types of APIs in gRPC, unary, server streaming, client streaming and bi directional streaming. Which holds a new way for communication, especially the streaming ones compared to REST.&lt;/p&gt;

&lt;p&gt;In this example, I have created a blogs service that handles all the CRUD operations with MongoDB, it has unary rpc for all the operations and a server streaming to list all the blogs from the database. You can see in action how simple it is, because as I said above you just need to care about the implementation, all other things are generated for you!&lt;/p&gt;

&lt;p&gt;To test the example yourself, check this &lt;a href="https://github.com/omdxp/mongo-grpc"&gt;repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>grpc</category>
      <category>microservices</category>
      <category>protobuf</category>
    </item>
    <item>
      <title>A dashboard in microservices architecture</title>
      <dc:creator>Omar Belghaouti</dc:creator>
      <pubDate>Mon, 26 Sep 2022 15:49:56 +0000</pubDate>
      <link>https://dev.to/omdxp/a-dashboard-in-microservices-architecture-ce3</link>
      <guid>https://dev.to/omdxp/a-dashboard-in-microservices-architecture-ce3</guid>
      <description>&lt;p&gt;Microservices are good (for some cases)! they help organize your architecture in a meaningful and more approachable way, they help teams to focus on specific tasks not to worry about other things. You can totally work separately and even with different technologies, all you need to do is a way to communicate between services, it could be REST, it could be gRPC or it could be both, why not!&lt;/p&gt;

&lt;p&gt;These past days I was working on a personal open source project that shows dealing with microservices in action. It honestly felt like building Lego parts as we did when were kids. Once you have an architecture in mind you can do the building blocks way easier, you'll just think about the execution and it is preferred to keep performance in mind.&lt;/p&gt;

&lt;p&gt;So without further ado, here's an explanation of what I did:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7I0fSKYN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yi1rhee9ugdapugm9b2r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7I0fSKYN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yi1rhee9ugdapugm9b2r.png" alt="pdash architecture" width="880" height="705"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First of all, there are 4 internal services ("Customers", "Suppliers", "Orders" and "Auth") which communicate with each other with gRPC. Each service is communicating with MongoDB as it's the chosen database for this example and each one of them have their collection in the DB.&lt;/p&gt;

&lt;p&gt;The "Customers" and "Suppliers" service are solely communicating with Redis when trying to get one customer or one supplier by id. it helps to get data from the memory cache and not getting from MongoDB each time. In my local machine, I got around 24ms when I get a supplier for example, when it's cached in Redis I got 3ms so you see the importance and performance that Redis provides.&lt;/p&gt;

&lt;p&gt;Of course, not all suppliers or customers are cached in memory but only the ones that are to be retrieved from MongoDB, at first time they are going to be retrieved from the database, but in the subsequence times they are going to be retrieved from the cache. And in this example, they are cached for 5 minutes just so we cannot fill memory with a lot of data. Also it is important to notice that when deleting or updating a supplier for example, the cache memory also needs to be updated.&lt;/p&gt;

&lt;p&gt;You may notice that there are some gRPC calls between services in the graph below, that is because it guarantees performant and simplicity to talk to each other on top of HTTP 2.0 as we spoke previously about it.&lt;/p&gt;

&lt;p&gt;In this example, there are gRPC calls when getting orders by customer id or supplier id we need to check if they exists in the database, so each service can do that specific job so the "Orders" service will check the existence of this supplier id or customers id by talking to "Suppliers" or "Customers" services respectively with gRPC. Also the "Auth" service help with authenticating the user by the used token in all the REST calls to all services, it will verify the token if it's valid and not expired as well.&lt;/p&gt;

&lt;p&gt;Now, let's talk about Nginx. Here it is working as a reverse proxy and load balancer between services, it forwards all the calls that are coming from the client to all services.&lt;/p&gt;

&lt;p&gt;Lastly, the dashboard is built with SolidJS as it helped me a lot with the built-in state management.&lt;/p&gt;

&lt;p&gt;To test yourself you can check the GitHub repo &lt;a href="https://github.com/omdxp/pdash"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>docker</category>
      <category>microservices</category>
      <category>grpc</category>
    </item>
  </channel>
</rss>
