<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mert Türkman on Medium]]></title>
        <description><![CDATA[Stories by Mert Türkman on Medium]]></description>
        <link>https://medium.com/@mertturkman?source=rss-f5f6fcbabf96------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UUCNevg7Uq6S8i9aEbOFdw.jpeg</url>
            <title>Stories by Mert Türkman on Medium</title>
            <link>https://medium.com/@mertturkman?source=rss-f5f6fcbabf96------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:45:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mertturkman/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Domain Driven Design Notes — Continuous Learning, Knowledge-Rich Design and Deep Model]]></title>
            <link>https://medium.com/@mertturkman/domain-driven-design-notes-continuous-learning-knowledge-rich-design-and-deep-model-4df4696f24a?source=rss-f5f6fcbabf96------2</link>
            <guid isPermaLink="false">https://medium.com/p/4df4696f24a</guid>
            <category><![CDATA[domain-modeling]]></category>
            <category><![CDATA[continuous-learning]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Mert Türkman]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 07:13:44 GMT</pubDate>
            <atom:updated>2023-03-13T07:13:44.677Z</atom:updated>
            <content:encoded><![CDATA[<h3>Domain Driven Design Notes — Continuous Learning, Knowledge-Rich Design and Deep Model</h3><p><a href="https://medium.com/@mertturkman/domain-driven-design-notlar%C4%B1m-continuous-learning-knowledge-rich-design-ve-deep-model-3f94ca49307b"><em>Türkçe versiyon için tıklayın.</em></a></p><p>Hi friends, in this article, I will talk about <strong>continuous learning</strong>, k<strong>nowledge-rich design</strong> and <strong>deep model</strong> which are important topics for <strong>domain driven design </strong>and I will touch on the subject through the edited version of the notes I have taken, I hope it will be useful, let’s start. :)</p><h3>Why Continuous Learning Is Important?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*MmAQwTP8CcKQdIosCeiZUg.jpeg" /></figure><p>As it can always happen, team members with <strong>domain knowledge</strong> may leave or restructuring may occur and the team may be disbanded and information will be fragmented. The important point here is that if the information that is not documented in the transfer process is not transferred in a healthy way, the information may be lost. Therefore, each team member should have sufficient knowledge about their <strong>domain</strong>.</p><p>Highly productive teams improve their knowledge by practicing continuous learning. For <strong>developers</strong>, this means developing and sharing technical knowledge as well as general <strong>domain</strong> <strong>modeling</strong> skills. At the same time, knowledge of the domain of the application is increased and refreshed.</p><p><strong>To summarize, teams practicing continuous learning gain important knowledge about;</strong></p><ul><li><strong>Technical knowledge</strong></li><li><strong>Domain modeling knowledge</strong></li><li><strong>Domain-specific know-how</strong></li></ul><p>Over time, <strong>developers</strong> who become <strong>domain experts</strong> themselves become the most effective <strong>knowledge crunchers</strong> and therefore the most productive and important team members.</p><h3>Why Do We Need Knowledge-Rich Design?</h3><p>Business processes and rules are as central to the domain as the concepts involved. When there is a real inconsistency between business rules, the <strong>knowledge crunching</strong> process with <strong>domain experts</strong> and <strong>developers</strong> intensifies. <strong>Domain experts</strong> often do not realize how complex the process is when resolving contradictions between all these business rules and filling the gaps appropriately. Clarification, elaboration, reconciliation and exclusion of rules is done through <strong>knowledge crunching</strong> in close cooperation with <strong>developers</strong>.</p><p>So, how can we make a distilled business rule more clear and accessible to everyone in the project? After all, it is unlikely that any <strong>domain expert</strong>, even under the guidance of a <strong>developer</strong>, will read this code to validate the rule, and it will be difficult for a technical person unfamiliar with this domain to make the connection between the requirement text and the code.</p><p>We can change the design to better capture this information. There are cases where more than one different business rule can be applied to a business process. For example, we can use a <strong>strategy pattern</strong> for one or more business rules that we want to apply. Thus, business rules can be expressed more clearly in <strong>the domain model</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*s3ohzwlc4JbpvHMR" /></figure><p>Let’s look at the example above for a better understanding. Here we have three ways to reach the airport: taxi, car and bus. Each of them has a different cost and therefore different business rules to calculate the cost. With this pattern, we can reflect the business rules in a more understandable way in our model, resulting in clear, information-rich models.</p><h3>What is Deep Model ?</h3><p>When models are first prepared, utility model elements are rarely included. As we begin to understand the needs of the domain and the application, superficial model elements that seem important but that we realize have no importance are discarded. As we get to the heart of the matter, abstractions emerge and updates are made on our models. After a certain period of knowledge and updates, they become models that reflect the process in a simple, understandable way as they get rid of superficiality. Such models are defined as <strong>deep models</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4df4696f24a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Domain Driven Design Notlarım — Continuous Learning, Knowledge-Rich Design ve Deep Model]]></title>
            <link>https://medium.com/@mertturkman/domain-driven-design-notlar%C4%B1m-continuous-learning-knowledge-rich-design-ve-deep-model-3f94ca49307b?source=rss-f5f6fcbabf96------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f94ca49307b</guid>
            <category><![CDATA[domain-modeling]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[continuous-learning]]></category>
            <dc:creator><![CDATA[Mert Türkman]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 07:11:20 GMT</pubDate>
            <atom:updated>2023-03-13T07:11:20.121Z</atom:updated>
            <content:encoded><![CDATA[<h3>Domain Driven Design Notlarım — Continuous Learning, Knowledge-Rich Design ve Deep Model</h3><p>Selam arkadaşlar, bu yazımda <strong>domain driven design </strong>için<strong> </strong>önemli konular olan <strong>continuous learning</strong>, <strong>knowledge-rich design ve deep modele </strong>dair bildiklerim ve almış olduğum notların düzenlenmiş hali üzerinden konura değineceğim, faydalı olmasını dilerim hadi başlayalım. :)</p><h3>Continuous Learning Neden Önemli ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MmAQwTP8CcKQdIosCeiZUg.jpeg" /></figure><p>Her zaman olabiliceği gibi <strong>domain bilgisine</strong> sahip ekip üyeleri ayrılabilir veya yeniden yapılanma gerçekleşip ekip dağılabilir ve bilgi parçalanır. Burda önemli olan nokta devir sürecinde dökümante edilmemiş bilgiler sağlıklı bir şekilde aktarılmamış ise bilgiler kaybolabilir. Bu yüzden her ekip üyesinin <strong>domaini</strong> hakkında yeterli seviyede bilgi sahibi olması gerekmektedir.</p><p>Yüksek üretkenliğe sahip ekipler, sürekli öğrenmeyi uygulayarak bilgilerini geliştirirler. <strong>Developerlar</strong> için bu, teknik bilginin yanı sıra genel <strong>domain modelleme</strong> becerilerinin geliştirilmesi ve paylaşılması anlamına gelir. Aynı zamanda uygulamanın domaini ile ilgili bilgi birikimi artar ve tazelenir.</p><p><strong>Özetlicek olursak sürekli öğrenmeyi uygulayan ekipler aşağıdaki konular hakkında önemli bilgiler edinirler</strong>;</p><ul><li><strong>Teknik bilgi</strong></li><li><strong>Domain modelleme bilgisi</strong></li><li><strong>Domaine özel bilgi birikimi</strong></li></ul><p>Zamanla, kendileri <strong>domain expert</strong> haline gelen <strong>developerlar</strong>, en etkili <strong>knowledge cruncher </strong>olurlar ve bu nedenle en verimli aynı zamanda önemli ekip üyeleri olurlar.</p><h3>Knowledge-Rich Design’a Niye İhtiyacımız Var?</h3><p>İş süreçleri ve kuralları ilgili kavramlar kadar domain merkezindedir. İş kuralları arasında gerçek bir tutarsızlık olduğunda <strong>domain expertler</strong> ve <strong>developerlar</strong> ile beraber yapılan <strong>knowledge crunching</strong> işlemide yoğunlaşır. <strong>Domain expertler</strong> genellikle tüm bu iş kuralları arasındaki çelişkileri çözerken ve boşlukları uygun bir şekilde doldururken sürecin ne kadar karmaşık olduğunun farkında değildir. Kuralların netleştirilmesi, detaylandırılması, uzlaştırılması ve kapsam dışı bırakılması <strong>developerlar</strong> ile yakın işbirliği içinde <strong>knowledge crunching</strong> yolu ile gerçekleştirilir.</p><p>Peki, damıtılmış bir iş kuralını projede daha açık ve herkezin erişebileceği hale nasıl getirebiliriz ? Sonuçta bir <strong>developerın</strong> rehberliğinde bile olsa herhangi bir <strong>domain expertin </strong>kuralı doğrulamak için bu kodu okuması pek muhtemel değil aynı zamanda bu domaine aşina olmayan teknik bir kişi gereksinim metni ile kod arasında bağlantı kurması zor olucaktır.</p><p>Bu bilgiyi daha iyi yakalamak için tasarımı değiştirebiliriz. Bir iş süreci için birden fazla farklı iş kuralının uygulanabileceği durumlar mevcuttur. Örneğin uygulanmasını istediğimiz bir veya birden çok iş kuralı için <strong>strateji pattern</strong> kullanabiliriz. Böylece iş kuralları <strong>domain modelde</strong> daha belirgin bir şekilde ifade edilebilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*s3ohzwlc4JbpvHMR" /></figure><p>Daha iyi anlaşılması için yukardaki örneği inceleyelim. Burda havalimanına erişmek için taxi, araba ve otobüs gibi üç yolumuz mevcuttur. Her birisinin maliyeti farklı olması nedeniyle maliyet hesaplamak için farklı iş kurallarına sahiptir. Bu pattern ile iş kurallarını modelimize daha anlaşılır şekilde yansıtabiliyoruz ve buda bize anlaşılır, bilgi zengini modellerin ortaya çıkmasını sağlıyor.</p><h3>Deep Model Nedir ?</h3><p>Modeller ilk hazırlandığında faydalı model unsurları nadiren yer alır. Domain ve uygulamanın ihtiyaçlarını anlamaya başladıkça önemli görünen ama bir önemi olmadığını anladığımız yüzeysel model unsurları bir kenara atılır. Başlangıçta aklımıza gelmeyen ancak meselenin özüne inildikçe soyutlamalar ortaya çıkar ve modellerimiz üzerinde güncellemeler yapılır. Belli bir sürelik bilgi birikiminden ve güncellemelerden sonra yüzeysellikten kurtulmasıyla birlikte süreci basit, anlaşılır şekilde yansıtan modellere dönüşürler. Bu tür modeller <strong>deep model</strong> olarak tanımlanır.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f94ca49307b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Retry and Circuit Breaker Pattern for Apache Kafka]]></title>
            <link>https://medium.com/@mertturkman/implementing-retry-and-circuit-breaker-pattern-for-apache-kafka-71bfea276124?source=rss-f5f6fcbabf96------2</link>
            <guid isPermaLink="false">https://medium.com/p/71bfea276124</guid>
            <category><![CDATA[events]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[retry]]></category>
            <category><![CDATA[circuit-breaker]]></category>
            <dc:creator><![CDATA[Mert Türkman]]></dc:creator>
            <pubDate>Mon, 05 Dec 2022 06:30:14 GMT</pubDate>
            <atom:updated>2022-12-05T06:30:14.060Z</atom:updated>
            <content:encoded><![CDATA[<p>Türkçe versiyonu için <a href="https://medium.com/@mertturkman/apache-kafka-i%CC%87%C3%A7in-retry-ve-circuit-breaker-pattern-uygulanmas%C4%B1-60930b4ff134">tıkla</a>.</p><p>Hello friends, in this article, I will explain what retry and circuit breaker pattern structures do and their importance, and then we will make a sample application with Apache Kafka, a high performance distributed messaging system. Let’s get started 😀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-m2DZIWQlfNB4TvB.png" /></figure><h3>What is Retry Pattern ?</h3><p><strong>Retry pattern</strong> is the name given to the pattern structure that allows the same operation to be retried instantly or within a certain time interval in case of an error in any service request or in the process of consuming the message.</p><p>The most important goal here is to increase the fault tolerance of the application, that is, to achieve the state in which the operation does not receive an error by retrying the operation when an error occurs.</p><p>There are three most commonly used retry pattern structures. These are;</p><ul><li><strong>Immediate retry</strong>: Retrying the process as soon as an error is received.</li><li><strong>Intervals retry: </strong>Repeating the process after receiving an error at certain intervals.</li><li><strong>Incremental intervals: </strong>In this structure, each time the operation is executed and an error is received, the interval for repeating the operation increases at a specified rate.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/0*GCcQj1o3gGthyRfu.png" /></figure><p>As in the example above, let’s imagine that an order is wanted to be created and that there is a problem in the service for any x reason. Naturally, we will get an error while doing this process, but what about the order that received an error? It will not disappear, of course, this is where the retry pattern gains importance. By applying the <strong>retry pattern</strong>, it is ensured that the same process is retried again and the successful situation is reached.</p><p>This pattern has disadvantages such as service overload or idempotency. If we are going to use <strong>retry pattern</strong>, our software architecture should be suitable for this structure.</p><h3>What is Circuit Breaker Pattern ?</h3><p><strong>Circuit breaker pattern</strong> is the pattern that allows the system to recover itself by stopping the creation of overload problems by repeating faulty transactions after a certain limit. <strong>Retry pattern</strong> is a necessary pattern for the retry pattern structure, retry of transactions that constantly receive errors can cause serious problems until the system is down, so it is better to use it with the retry pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*-quk6i57Sf_V6EWC.png" /></figure><p>There are three states in the circuit breaker structure. These are;</p><ul><li><strong>Closed</strong>: This refers to a situation where the application works as expected and all data traffic proceeds in a healthy manner.</li><li><strong>Open</strong>: This is when the system stops data traffic to allow the system to recover.</li><li><strong>Half Open</strong>: After a defined period of time, the data flow of requests continues for a certain number or duration to test the status of the service. If the error limit is exceeded again, it should go to the open state, but if the data flow is healthy, it should go to the closed state.</li></ul><h3>Sample Project</h3><p>Friends, we will make a simple consumer producer application in our sample project, but the different points are that it will use retry, circuit breaker pattern structures and can work in a concurrency way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lR5ziALkNtRd7KhGmatZcw.png" /></figure><p>To explain it simply, our processes are actually as you can see in the graphic above. There are 3 topics in our project; main topic, retry topic and dead topic. The main topic is consumed by the order consumer and the message is produced to the retry topic because an error occurred. By the retry consumer, the message can be consumed n times until the operation is successful and if an error is received n times, the message is discarded to the dead topic.</p><p>Again, with the concurrency structure here, the messages are consumed faster because the operations are performed simultaneously.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fd94dbd0668da38c20ee82042622450/href">https://medium.com/media/3fd94dbd0668da38c20ee82042622450/href</a></iframe><p>Retry and concurrency structures are managed by BaseConsumer. The message is consumed in the number or time interval defined in the configuration and these messages can be processed simultaneously. If an error is received, the message can be consumed n times in the defined time interval and if it continues to receive errors, message produced to dead topic.</p><p>You can access the source code of the project <a href="https://github.com/mertturkman/KafkaRetrySample">here</a>.</p><p>I tried to explain as clearly as I could, I hope it was useful 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71bfea276124" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Kafka İçin Retry Ve Circuit Breaker Pattern Uygulanması]]></title>
            <link>https://medium.com/@mertturkman/apache-kafka-i%CC%87%C3%A7in-retry-ve-circuit-breaker-pattern-uygulanmas%C4%B1-60930b4ff134?source=rss-f5f6fcbabf96------2</link>
            <guid isPermaLink="false">https://medium.com/p/60930b4ff134</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[circuit-breaker]]></category>
            <category><![CDATA[retry]]></category>
            <dc:creator><![CDATA[Mert Türkman]]></dc:creator>
            <pubDate>Mon, 05 Dec 2022 06:22:43 GMT</pubDate>
            <atom:updated>2022-12-05T06:22:43.016Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba arkadaşlar, bu yazımda retry ve circuit breaker pattern yapılarının ne işe yaradıklarını ve önemini anlatıcam ardından yüksek performanslı dağıtık mesajlaşma sistemi olan Apache Kafka ile örnek bir uygulama yapıcağız. Haydi Başlayalım 😀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-m2DZIWQlfNB4TvB.png" /></figure><h3>Retry Pattern Nedir ?</h3><p><strong>Retry pattern</strong>, herhangi bir servis isteğinde veya mesajın consume edilme sürecinde hata oluşması durumunda aynı işlemin anında veya belirli süreler aralığında tekrar denenmesini sağlayan pattern yapısına verilen isimdir.</p><p>Burdaki en önemli amaç uygulamanın hata toleransını arttırmaktır, yani herhangi bir hata oluştuğunda işlemi tekrar deneyerek yapılan işlemin hata almadığı durumu elde etmek.</p><p>En çok kullanılan üç adet retry pattern yapısı mevcuttur. Bunlar;</p><ul><li><strong>Immediate retry</strong>: Hata alındığı anda işlemin tekrar denenmesi</li><li><strong>Intervals retry: </strong>Belirli aralıklar ile hata alının işlemin tekrarlanması</li><li><strong>Incremental intervals: </strong>Bu yapıda işlem her gerçekleşip hata alındığında işlemin tekrarlanma aralığı belirlenen oranda artar.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/0*GCcQj1o3gGthyRfu.png" /></figure><p>Yukarıdaki örnekteki gibi , bir siparişin oluşturulmak istendiğini ve bu sırada serviste herhangi bir x sebeple problem oluştuğunu düşününelim. Doğal olarak bu işlem yapılırken hata alacağız buraya kadar tamam peki hata alan sipariş ne olucak ? Yok olucak değil tabiki işte retry pattern bu noktada önem kazanıyor. Aynı işlemin tekrar denenerek başarılı olunan duruma erişilmesini sağlanır <strong>retry pattern</strong> uygulanarak.</p><p>Bu pattern servisin overload olmasını veya idempotency gibi bazı problemlere yol açabilicek dezavantajlara sahiptir. <strong>Retry pattern</strong> kullanıcaksak yazılım mimarimiz bu yapıya uygun olmalıdır.</p><h3>Circuit Breaker Pattern Nedir ?</h3><p><strong>Circuit breaker pattern, </strong>hatalı işlemlerin<strong> </strong>tekrar ederek overload problemi yaratılmasını belirli bir sınırdan sonra durdurarak sistemin kendisini toparlamasına izin veren patterndir. Retry pattern yapısı için gerekli bir patterndir, sürekli hata alan işlemlerin retry edilmesi sistemin down olmasına kadar ciddi problemlere yol açabilir bu nedenle retry pattern ile kullanılması daha doğru olucaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*-quk6i57Sf_V6EWC.png" /></figure><p><strong>Circuit breaker </strong>yapısında üç durum vardır. Bunlar;</p><ul><li><strong>Closed</strong>: Uygulamanın beklendiği gibi çalıştığı ve tüm veri trafiğinin sağlıklı bir şekilde ilerlediği durumu ifade eder.</li><li><strong>Open</strong>: Sistemin kendini toparlaması için veri trafiğini durdurma durumudur.</li><li><strong>Half Open</strong>: Tanımlanan süre sonra servisin durumunu test etmek için belirli bir sayıda veya sürede isteklerin veri akışının devam etmesi durumudur. Eğer hata limiti yine aşılırsa <strong>open</strong> durumuna geçmelidir ama veri akışı sağlıklı bir şekilde sağlanırsa <strong>closed</strong> durumuna geçmelidir.</li></ul><h3>Örnek Proje</h3><p>Arkadaşlar örnek projemizde basit bir consumer producer uygulaması yapıcaz, lakin farklı olan noktaları retry, circuit breaker pattern yapılarını kullanıcak ve concurrency bir şekilde çalışabilicek olmasıdır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lR5ziALkNtRd7KhGmatZcw.png" /></figure><p>Basit olarak açıklamak gerekirse aslında süreçlerimiz yukarıdaki grafikte gördüğünüz gibidir. Projemizde 3 topic mevcut bunlar; main topic, retry topic ve dead topic. Order consumer tarafından main topic consume edilir ve hata oluştuğundan mesaj retry topic’e produce edilir. Retry consumer tarafından işlem başarılı olana kadar n kez consume edilebilir ve n kez hata alınırsa mesaj dead topice atılır.</p><p>Yine burda concurrency yapısı ile işlemler eş zamanlı bir şekilde gerçekleştiği için mesajlarlar daha hızlı consume edilir.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fd94dbd0668da38c20ee82042622450/href">https://medium.com/media/3fd94dbd0668da38c20ee82042622450/href</a></iframe><p>Retry ve concurrency yapıları BaseConsumer tarafından yönetilmektedir. Configte tanımlanan sayı veya süre aralığında mesaj consume ediliyor ve bu mesajlar eş zamanlı olarak işlenebiliyor. Eğer hata alınırsa mesaj tanımlanan zaman aralığında n kez consume edilebilir ve hata almaya devam ederse dead topice produce edilir.</p><p>Projenin kaynak kodlarına <a href="https://github.com/mertturkman/KafkaRetrySample">burdan</a> erişebilirsiniz.</p><p>Elimden geldiğince anlaşılır şekilde anlatmaya çalıştım umarım faydalı olmuştur 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60930b4ff134" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Domain Driven Design Notes — Domain Model and Knowledge Crunching]]></title>
            <link>https://medium.com/@mertturkman/domain-driven-design-notes-domain-model-and-knowledge-crunching-15c4242630e9?source=rss-f5f6fcbabf96------2</link>
            <guid isPermaLink="false">https://medium.com/p/15c4242630e9</guid>
            <category><![CDATA[ddd]]></category>
            <category><![CDATA[domain-modelling]]></category>
            <category><![CDATA[domain-model]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[knowledge-crunching]]></category>
            <dc:creator><![CDATA[Mert Türkman]]></dc:creator>
            <pubDate>Mon, 08 Aug 2022 07:43:42 GMT</pubDate>
            <atom:updated>2022-08-08T07:43:42.649Z</atom:updated>
            <content:encoded><![CDATA[<h3>Domain Driven Design Notes — Domain Model and Knowledge Crunching</h3><p><a href="https://medium.com/@mertturkman/domain-driven-design-notlar%C4%B1m-domain-model-ve-knowledge-crunching-594945bb4074"><em>Türkçe versiyon için tıklayın.</em></a></p><p>Hi friends, I will talk about <strong>domain model</strong> and <strong>knowledge crunching</strong> which are the building blocks for <strong>domain driven design</strong>, through the edited version of my notes I have taken in this article. I hope it helps. Let’s get started. :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*vD8q3y46spffMnMNhTD87Q.jpeg" /></figure><h3>Why Do We Need The Domain Model ?</h3><p>Every application should have the purpose of being used to solve a specific problem or improve an existing system, and yet it has at least one <strong>domain</strong> (interest) for its purpose. While the applications we have developed while achieving these goals may be abstract concepts such as accounting, banking and finance, they may be from different sectors with concrete concepts such as transportation and defense industry and may require different <strong>domain</strong> information.</p><p>For example, let’s say we want to develop an application related to the finance sector, we need to have knowledge about the processes and concepts used to create this application, but as I have experienced before, there can be complex processes and concepts that are very difficult to understand in the finance sector. I don’t think we can be a finance expert until the deadline of the application to understand these concepts and processes. :) So how can we develop this application even though we have no knowledge of finance, we need to find a different solution, here we need a <strong>domain model</strong>.</p><h3>So What Is This Domain Model ? What Does It Do ?</h3><p>A<strong> domain model</strong> is a selected, abstracted and organized form of information for us to understand processes and concepts. A domain model is definitely not just a diagram, it is the information that is wanted to be understood through this diagram. At the same time, this information should be meticulously selected, abstracted, simplified and made easier to understand.</p><p>Another point to be considered while doing <strong>domain modeling</strong> is not to try to make a “<strong>realistic</strong>” <strong>model</strong> as much as possible. <strong>Our domain model</strong> should loosely represent reality. A model in which we explain every point one by one will not be understandable because it will be very complex and complex, then our model will have no importance.</p><p>As the<strong> domain model</strong> evolves, it becomes a tool for organizing the information that continues to flow throughout the project. The<strong> model </strong>focuses on requirements analysis. It interacts closely with <strong>software</strong> and <strong>design</strong>. These models are never perfect, they are constantly evolving. <strong>Domain</strong> should be practical and useful in making sense.</p><p>Here, we can examine the movie “The Theory of Everything”, which reflects the life of Stephen Hawking, as an example of a biography. The movie has three main themes; his relationship with his friends, his family, and his research on astrophysics. Let’s think about the preparation stage of the script, the purpose of the screenwriter is not to reflect everything as it is, but to simplify his complex life by choosing the parts of his life that he thinks are important and to arrange it in a way suitable for the audience. It is similar to the modeling process we have mentioned, isn’t it? :)</p><h3>Benefits of The Domain Model</h3><ul><li>Since <strong>the</strong> <strong>domain model</strong> shapes our application design, there is an important link with our application. Every change in our <strong>model</strong> also causes changes in our application and improves it.</li><li><strong>The</strong> <strong>domain model</strong> forms the backbone of the common language called “<strong>Ubiquitous Language</strong>”, which we expect to be understood and used by the whole team, which we will discuss in detail later. Thanks to the developed common language, they can communicate with <strong>domain experts</strong> comfortably and easily without any translators, without leaving any open ends suitable for misunderstanding.</li><li><strong>The</strong> <strong>domain model</strong> contains information that is selected and abstracted and simplified. The purpose here is to make it easier for the team to learn about the application and to distinguish important elements.</li></ul><h3>What is Knowledge Crunching ? Why Do We Need It ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Vvln2rSWVQhbnu5LD1xi4g.jpeg" /></figure><p><strong>Developers</strong> and <strong>domain experts</strong> collaboratively discuss the<strong> domain experts</strong> knowledge and only those relevant to the application are selected and abstracted and transformed into simplified information. This process is called <strong>knowledge crunching</strong>.</p><p>The goal is to obtain <strong>a</strong> <strong>domain model</strong> of what the application should do, how it should do it, and what the technical implementation should be.</p><p>In the old waterfall method used, <strong>analysts</strong> and <strong>domain experts</strong> talk about the application together, and the <strong>analysts</strong> abstract and organize the information and transfer it to the <strong>developers</strong>. Since there is no feedback in this approach, it is not possible to achieve sustainable success in complex and complex projects. <strong>Analysts</strong> are fully authorized to create a domain model based on the information they obtain from <strong>domain experts</strong>. <strong>Developers</strong> do not have the chance to learn anything or gain experience with the first version of the software. Information flows in one direction and this indicates <strong>bottlenecks</strong> that may occur in the future.</p><p>With the iterative method, information flows in many directions as <strong>developers</strong> and <strong>domain experts</strong> collaborate. In this method, infrastructre or UI related development should not be done for the application at the initial stage. It is the behavior of the software that is important at the initial stage. Since the process is iterative, <strong>knowledge crunching</strong> is done over the extracted prototype and the domain model is rearranged. Of course, since the application is dependent on <strong>the</strong> <strong>domain model</strong>, changes are made on the application. This cycle continues like this.</p><h4><strong>Effective modeling is based on;</strong></h4><ol><li><strong>The link between the model and the application</strong>; The implementation must be strictly model-based. Every time the model is updated it must be updated in the app.</li><li><strong>Development of a model-based language</strong>; The model should contain terms that are the basis of a common language for both domain experts and developers.</li><li><strong>Developing a knowledge-rich model</strong>; It should be more than a representation of model data structures. It should contain all kinds of information such as data structures, objects, behaviors, mandatory rules.</li><li><strong>Distillation of the model</strong>; Important concepts are added to the model as the model evolves, but concepts that are not equally important should be removed when they prove not to be useful or central.</li><li><strong>Brainstorming and experiments</strong>; Brainstorming and experiment meetings between domain experts and developers, where intense experimentation and discussion take place, provide a distilled knowledge-rich model.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15c4242630e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Domain Driven Design Notlarım — Domain Model ve Knowledge Crunching]]></title>
            <link>https://medium.com/@mertturkman/domain-driven-design-notlar%C4%B1m-domain-model-ve-knowledge-crunching-594945bb4074?source=rss-f5f6fcbabf96------2</link>
            <guid isPermaLink="false">https://medium.com/p/594945bb4074</guid>
            <category><![CDATA[knowledge-crunching]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[ddd]]></category>
            <category><![CDATA[domain-model]]></category>
            <category><![CDATA[domain-modelling]]></category>
            <dc:creator><![CDATA[Mert Türkman]]></dc:creator>
            <pubDate>Mon, 08 Aug 2022 07:39:25 GMT</pubDate>
            <atom:updated>2022-08-08T08:56:03.215Z</atom:updated>
            <content:encoded><![CDATA[<h3>Domain Driven Design Notlarım — Domain Model ve Knowledge Crunching</h3><p>Selam arkadaşlar, bu yazımda <strong>domain driven design </strong>için<strong> </strong>yapı taşı olan <strong>domain model </strong>ve<strong> knowledge crunchinge</strong> dair bildiklerimi almış olduğum notların düzenlenmiş hali üzerinden değineceğim. Faydalı olmasını dilerim. Haydi başlayalım. :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vD8q3y46spffMnMNhTD87Q.jpeg" /></figure><h3>Niye Domain Modele İhtiyacımız Var ?</h3><p>Her uygulamanın, belirli bir soruna çözüm getirmek veya mevcut bir sistemi iyileştirmek için kullanılması amacı olması gerekmektedir ve bununla beraber amacı doğrultusunda en az bir <strong>domaine</strong> (ilgi alanına) sahiptir. Bu amaçları gerçekleştirirken geliştirdiğimiz uygulamalar muhasebe, bankacılık ve finans gibi soyut kavramlar olabilirken ulaşım ve savunma sanayi gibi somut kavramların olduğu farklı sektörlerden olabilir ve farklı <strong>domain</strong> bilgileri gerektirebilir.</p><p>Örneğin finans sektörü ile ilgili bir uygulama geliştirmek istediğimizi düşünelim, bu uygulamayı ortaya çıkarmak için kullanılan süreçler ve kavramlar hakkında bilgimiz olması gerekli ama benimde daha önceden tecrübe ettiğim gibi finans sektöründe kompleks süreçler ve anlaşılması çok zor kavramlar olabiliyor. Bu kavramları ve süreçleri anlamak için uygulamanın deadline zamanına kadar bir finans uzmanı olabiliceğimize pek ihtimal vermiyorum. :) Peki finans bilgimiz olmadığı halde bu uygulamayı nasıl geliştirebiliriz, farklı bir çözüm bulmamız gerekli işte burda bir <strong>domain modele </strong>ihtiyaç duyuyoruz<strong>.</strong></p><h3>Peki Bu Domain Model Nedir? Ne İşe Yarar ?</h3><p><strong>Domain model,</strong> süreçleri ve kavramları anlamamız için bilginin seçilmiş, soyutlanmış ve düzenlenmiş şeklidir. Bir <strong>domain model </strong>kesinlikle sadece bir diyagramdan ibaret değildir, bu diyagram üzerinden anlaşılması istenen bilgidir. Aynı zamanda bu bilgiler titizlikle seçilmiş, soyutlanarak basitleştirilmiş ve anlaşılması daha kolay hale getirilmiş olmalıdır.</p><p><strong>Domain modelleme</strong> yapılırken dikkat edilmesi gereken başka bir noktada mümkün olduğunca “<strong>gerçekçi</strong>” bir model yapılmaya çalışılmamasıdır. <strong>Domain modelimiz</strong> gerçekliği gevşek bir şekilde temsil etmelidir. Her noktayı bire bir anlattığımız bir model çok karmaşık ve kompleks olucağı için anlaşılabilir olmayacaktır, o zamanda modelimizin hiçbir önemi kalmaz.</p><p><strong>Domain model</strong> geliştikçe, proje boyunca akmaya devam eden bilgileri düzenlemek için bir araç haline gelir. <strong>Model</strong>, gereksinim analizine odaklanır. <strong>Yazılım</strong> ve <strong>tasarım</strong> ile yakın etkileşim içindedir. Bu modeller asla mükemmel değildir, sürekli evrim geçirirler. <strong>Domain</strong> anlamlandırmada pratik ve kullanışlı olmalıdır.</p><p>Burda bir biyografi anlatımı olarak Stephen Hawking’in hayatını yansıtan “Her Şeyin Teorisi” filmini örnek olarak inceleyebiliriz. Filmin üç ana konusu vardır; arkadaşları, ailesi ile olan ilişkisi ve astrofizik bilimi üzerine yapmış olduğu araştırmaları. Senaryonun hazırlanma aşamasını düşünelim senaristin amacı her şeyi olduğu gibi yansıtmak değil hayatının önemli olduğunu düşündüğü kısımları seçerek karmaşık olan yaşamını basitleştirmek ve seyirciye uygun bir şekilde düzenlemektir. Değinmiş olduğumuz <strong>modelleme</strong> sürecine ne kadarda benziyor değil mi :)</p><h3>Domain Modelin Faydaları</h3><ul><li><strong>Domain model</strong>, uygulama tasarımımızı şekillendirdiği için uygulamamız ile önemli bir bağ mevcuttur. Modelimizdeki her değişiklik de uygulamamızda değişikliğe sebep olup geliştirmektedir.</li><li><strong>Domain model</strong>, daha sonra detaylı olarak değineceğimiz tüm ekip tarafından anlaşılıp kullanılmasını beklediğimiz “<strong>Ubiquitous Language</strong>” olarak adlandırılan ortak dilin bel kemiğini oluşturur. Geliştirilen ortak dil sayesinde <strong>domain expertler</strong> ile herhangi bir çevirmen olmadan rahat ve kolay bir şekilde herhangi bir yanlış anlaşılmaya uygun açık uç bırakmadan anlaşabilirler.</li><li><strong>Domain model</strong>, seçilip soyutlanarak sadeleştirilmiş bilgileri içerir. Burdaki amaç ekibin uygulama hakkında bilgi edinmesini kolaylaştırmak ve önemli unsurları ayırt edebilmeyi sağlamak.</li></ul><h3>Knowledge Crunching Nedir ? Niye İhtiyacımız Var ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*Vvln2rSWVQhbnu5LD1xi4g.jpeg" /></figure><p><strong>Developerlar</strong> ve <strong>domain expertler</strong> bir işbirliği halinde, <strong>domain expertlerin</strong> bilgilerini tartışır ve bunların sadece ve sadece uygulama ile ilgili olanları seçilerek soyutlanır, basitleştirilmiş bilgilere dönüştürülür. Bu sürece <strong>knowledge crunching </strong>denir.</p><p>Amaç, uygulamanın ne yapması gerektiği, bunu nasıl yapması gerektiği ve teknik uygulamanın ne olması gerektiğine dair bir <strong>domain mode</strong>l elde etmektir.</p><p>Kullanılan eski <strong>waterfall</strong> yönteminde, uygulama hakkında <strong>analistler</strong> ile <strong>domain expertler</strong> birlikte konuşur ve analistler bilgiyi soyutlayıp düzenleyerek <strong>developerlara</strong> aktarır. Bu yaklaşımda <strong>feedback </strong>olmadığından<strong> </strong>kompleks ve karmaşık projelerde sürdürülebilir bir başarı elde etmek mümkün değildir. <strong>Analistler</strong> <strong>domain expertlerden </strong>elde ettikleri bilgilere dayanarak bir domain model oluşturmada tam yetkilidirler. <strong>Developerlar </strong>bir şey öğrenme ya da yazılımın ilk versiyonu ile deneyim kazanma şansına sahip değildir. Bilgi tek yönde akar ve buda ileride oluşabilicek <strong>bottlenecklere</strong> işaret etmektedir.</p><p><strong>Yinelemeli</strong> yöntem ile, <strong>developerlar</strong> ve <strong>domain expertler</strong> iş birliği halinde olduğu için bilgi çok yönlü akar. Bu yöntemde başlangıç aşamasında uygulama için infrastructre veya UI ile ilgili geliştirme yapılmamalıdır. Başlangıç aşamasında önemli olan yazılımın davranışıdır. Süreç yinelemeli olduğu için çıkartılan protatip üzerinden tekrar <strong>knowledge crunching </strong>yapılır ve <strong>domain model </strong>yeniden düzenlenir. Tabiki uygulama, <strong>domain modele</strong> bağlı oldu için uygulama üzerinde değişiklikler yapılır. Bu döngü devamlı olarak böyle ilerler.</p><p>En önemli dikkat edilmesi gereken noktalardan bazılarıda, <strong>developerların</strong> <strong>domainle</strong> olan ilgisi, uygulamanın arkasındaki ilkelerin ve süreçlerin anlaşılmasıdır. Böyle yapmazsak <strong>domain modelleme</strong> işlemi tam anlamı ile başarılı olmıyacaktır ayrıca daha önce bahsettiğimiz <strong>bottleneckler </strong>oluşmasına sebep olucaktır.</p><h4><strong>Etkili modelleme aşağıdakilere dayanmaktadır</strong>;</h4><ol><li><strong>Model ve uygulama arasındaki bağ</strong>; Uygulama kesinlikle modele dayalı olmalıdır. Model her güncellendiğinde uygulamada güncellenmelidir.</li><li><strong>Modele dayalı bir dilin geliştirilmesi</strong>; Model, hem domain expertler hemde developerlar için ortak bir dilin temeli olan terimleri içermelidir.</li><li><strong>Bilgi açısından zengin bir model geliştirmek</strong>; Model veri yapılarının bir temsilinden daha fazlası olmalıdır. Veri yapıları, nesneler, davranışlar, zorunlu kurallar gibi her çeşit bilgiyi içermelidir.</li><li><strong>Modelin damıtılması</strong>; Önemli kavramlar model geliştikçe modele eklenir, ancak aynı derecede önemli olmayan kavramlar yararlı veya merkezi olmadıkları kanıtlandığında çıkarılmalıdır.</li><li><strong>Beyin fırtınası ve deneyler</strong>; Domain expertler ve developerlar arasında, yoğun deney ve tartışmaların gerçekleştiği beyin fırtınası ve deney toplantıları, damıtılmış bilgi açısından zengin bir model sağlar.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=594945bb4074" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Kafka’ya Giriş, Avantajları ve Kullanımı]]></title>
            <link>https://medium.com/@mertturkman/apache-kafkaya-giri%C5%9F-avantajlar%C4%B1-ve-kullan%C4%B1m%C4%B1-2f2d4920450c?source=rss-f5f6fcbabf96------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f2d4920450c</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[broker]]></category>
            <category><![CDATA[message]]></category>
            <category><![CDATA[nets]]></category>
            <dc:creator><![CDATA[Mert Türkman]]></dc:creator>
            <pubDate>Tue, 21 Dec 2021 08:13:27 GMT</pubDate>
            <atom:updated>2021-12-21T08:13:27.978Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba arkadaşlar, bu yazımda yüksek performanslı bir mesajlaşma sistemi olan Apache Kafka’dan bahsedeceğim. Apache Kafka ekosistemine dahil olan broker, topic, partition, producer ve consumer gibi bir çok konuya değinip devamında yaptığım örnek bir projeyi detaylı olarak anlatıcam. <br>Haydi Başlayalım 😀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*DG-2NAVnMuxzFvtBjrYGPQ.png" /></figure><h4><strong>Apache Kafka Nedir ?</strong></h4><p>Apache Kafka, LinkedIn tarafından geliştirilmiş olup 2011 yılında piyasaya sürülen açık kaynak kodlu dağıtık mesajlaşma sistemidir. Apache yazılım vakfı tarafından hala geliştirilmekte olup scala ve java yazılım dilleri kullanılmıştır. Amacı gerçek zamanlı bir şekilde düşük gecikmeler ile yüksek performanslı bir mesajlaşma sistemi oluşturmak. Ben bundan sonra kısaca <strong>Kafka</strong> dicem.</p><h4>Kafka Temel Kavramları</h4><ul><li><strong>Topic, </strong>adındanda belli olduğu gibi<strong> </strong>aynı türden bir veri akışı olan Kafka’daki mesajların mantıksal kategorileridir. Gönderilen mesajları kategorilere, gruplara ayırmak için kullanılır aynı zamanda mesajlar burada saklanır ve birden çok partition’dan oluşamaktadır.</li><li><strong>Partition</strong>, veri depolama sistemlerindeki sharding yapısına benzer ve Kafka’nın ölçekleme yapısının arkasındaki temel kavramdır. Diyelim ki sistemimiz gerçekten popüler hale geldi ve bu nedenle saniyede milyonlarca günlük mesajı var. Şimdi, topic’in bulunduğu node, gelen tüm verileri tutamıyor. Bunu başlangıçta düğümümüze daha fazla depolama ekleyerek, yani dikey ölçeklendirme ekleyerek çözebiliriz. Ancak hepimizin bildiği gibi, dikey ölçeklemenin bir sınırı vardır, bu eşiğe ulaşıldığında yatay olarak ölçeklendirmemiz gerekir, bu da daha fazla düğüm eklememiz ve verileri düğümler arasında bölmemiz gerektiği anlamına gelir. Bir konunun verilerini birden çok akışa böldüğümüzde, bu küçük akışların tümüne o konunun “partition” adını veririz.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gEMTrM75SdIPBrvw8l7Kog.png" /></figure><p>Yukardaki görüntüde, tek bir topic’in 4 partition’a sahip olduğu ve hepsinin farklı bir veri kümesine sahip olduğunu göstermektedir. Burada gördüğünüz bloklar, o bölümdeki farklı mesajlardır. Örnek olarak topic’i bir dizi olarak düşünelim, bellek kapasite kısıtı nedeniyle tek diziyi 4 farklı küçük diziye böldük, topic’e yeni bir mesaj yazdığımızda ilgili partition seçilir ve daha sonra dizinin sonuna o mesaj eklenir.</p><ul><li><strong>Offset</strong>, mesajların yazılma sırasını belirten bir değerdir. Mesajlar partition’lara sıralı olarak, değiştirilemez olarak eklenirler ve artan şekilde bir kimlik değeri alırlar. Mesaj okuma işleminden sonra kaybolmaz, tekrar erişim mümkündür. Offset yapısı sayesinde partition’a yazma ve okuma işlemleri paralel bir şekilde yapılabilir.</li><li><strong>Broker</strong>, topicleri ve içindeki partitionları barındıran sunuculardır. Bir Kafka broker, producer<strong> </strong>tarafından gönderilen<strong> </strong>mesajları alır ve bunları benzersiz bir offset ile partition’da saklar. Consumer’ların topic ve partition’a göre sıralı bir şekilde belirli offset’teki mesajı almamızı sağlar. Kafka dağıtık bir yapıya sahip olduğu için her broker’da sadece belirli topic ve partitionlar bulunur.</li><li><strong>Cluster</strong>, bir veya daha fazla broker’dan oluşan sunucu kümesine verilen isimdir. Yük dengesini korumak ve hata toleransını arttırmak için genellikle birden çok broker<strong> </strong>kullanılır. Broker’lar stateless bir yapıya sahiptir, bu nedenle broker state’lerini korumak için ZooKeeper kullanırlar. Bir broker, saniyede yüz binlerce okuma ve yazma işlemini gerçekleştirebilir ve her broker, performans etkisi olmadan terabyte’larca iletiyi işleyebilir. Bir broker’a bağlandığınızda, buna <strong>”bootstrap server”</strong> denir ve tüm cluster’a bağlanmış olursunuz. Yani cluster’daki her broker aslında bir bootstrap server’dır.</li><li><strong>Zookeeper</strong>, broker’ların statelerini saklar, yönetmek ve koordine etmek için kullanılır. Yeni bir broker ayağa kalktığında, down olduğunda, topic’e partition eklendiğinde veya silindiğinde zookeeper broker’lara bildirim gönderir. Alınan bildirime göre, producer ve consumer karar verir ve görevlerini başka bir broker ile koordine etmeye veya farklı bir partition’la çalışmaya başlayabilir.</li><li><strong>Producer</strong>, görevi mesajları broker’lara göndermektir. Broker’a mesaj gönderildiği zaman configuration’a göre mesajın partition’a yazılıp yazılmadığı kontrol edilebilir haricinde bunun kontrolünüde ignore edebiliriz. Mesaj anahtarı (message key) tanımlanmışsa, partition’a yazma işlemi anahtar değerine göre yapılır aynı anahtar değerine sahip mesajlar aynı partitiona yazılır buda bize event sıralama (event ordering) yapısını sağlar. Herhangi bir mesaj anahtarı belirtilmediğinde yükü partition’lar arasında bölmek için round robin yapısını kullanıcaktır.</li><li><strong>Consumer</strong>, bir veya birden fazla topic’in partition’larına yazılmış mesajları okumaktan sorumlu uygulamadır. Mesajları offset bilgisine göre sıralı bir şekilde okur ve mesajlar okundukça configution’a göre offset bilgisi otomatik veya manuel olarak güncellenir. Consumer birden fazla partition’ı okuyabilir ama bir partition’ı birden fazla consumer okuyamaz. Her partition için offset bilgileri “__consumer_offsets” topic’inde saklanır. Herhangi bir consumer down olup tekrar çalıştığında “__consumer_offsets” içindeki offset bilgisini alıp okuma işlemine devam edilir.</li><li><strong>Consumer group</strong>, consumerların oluşturmuş olduğu bir uygulama topluluğudur. Bu gruptaki consumer’ların her biri partition başına benzersiz offsetlere sahiptir. Farklı gruptaki consumer’lar okuduğu partition için farklı offsetlere sahiplerdir.</li><li><strong>Replication, </strong>partition replikalarının farklı broker’larda saklanmasıdır.<strong> </strong>Herhangi bir broker’ın down olması durumunda o broker’daki lead partition’a ulaşılamaz bu durumda diğer broker’lardaki bir replika partition, lead olarak seçilir ve tüm süreç aksamadan devam eder.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avNB5Db13R0_9AHKE7M1kA.png" /></figure><p>Yukarıdaki diagramda göründüğü gibi kafka’nın mimarisi</p><p><strong>Kafka’nın Avantajları;</strong></p><ol><li>Hızlı ve kolay bir şekilde ölçeklenebilen dağıtık bir sistemdir.</li><li>Yüksek performans sunar. Terabaytlarca depolanmış mesajla uğraşırken bile sabit performans sunar, hem <strong>producer</strong>’lar hem de <strong>consumer</strong>’lar için yüksek verim sağlar.</li><li>Son derece dayanıklıdır, arıza durumunda <strong>consumer</strong>’ları otomatik olarak dengeler.</li><li>Çok güvenilirdir. Kafka’da, mesajların kopyalama işlemleri yapılır, <strong>topic replication</strong> yapısı sayesinde son derece dayanıklı bir mesajlaşma sistemi sağlar.</li><li>Kendi içinde <strong>message ordering</strong> yapısına sahiptir. Aynı anahtar değerine sahip mesajlar daha önce gönderilmiş <strong>partition</strong>’lara tekrar gönderilir.</li><li>Mesajlar consume edildikten sonra değil belirli bir süre geçtikten sonra (<strong>retention</strong>) silinir. Default olarak silinme süresi 7 gündür bu süre ihtiyaca göre değiştirilebilir.</li><li>Kafka’nın diğer teknolojilerle iletişim kurabilmesi için bir çok <strong>connectors</strong> geliştirilmiştir. Örneğin: JDBC Source and Sink, Replicator, Elasticsearch Service Sink, Debezium(SQL Server, PostgreSQL, MySQL) gibi…</li><li>Açık kaynak kodlu olduğu için ilerleyen zamanlarda herhangi bir lisans veya kullanım ücreti talebi söz konusu olamaz.</li></ol><p><strong>Kafka’nın Dezavantajları;</strong></p><ol><li>Gelişmiş sistem yönetimi, takip ve durum kontrolü gibi araçları henüz mevcut olmadığı için kontrolü zordur.</li><li>RabbitMQ’daki gibi exhange ve routing key yapılarına sahip değildir bu yüzden farklı topic’ler arasında mesaj yönlendirmeleri yapılamaz.</li><li>Dağıtık bir yapıda çalışabilmesi için Zookeeper’a<strong> </strong>ihtiyaç duyar.</li><li>.NET için <strong>Confluent</strong> gibi third party bir sdk kullanılmalıdır.</li></ol><h4>Hangi İşlemler İçin Kafka’yı Kullanmalıyız ?</h4><p>Kafka, bir çok avantaja sahip olmasına rağmen ihtiyaca yönelik kullanmamız gereklidir. Çok yoğun bir mesaj trafiği yoksa, mesajların giderek artıcağı ölçeklenmeye ihtiyaç duyabileceğimiz bir yapı gerekli değilse ve mesajların kalıcılığı önemli değilse Kafka’ya ihtiyaç duymayız. Aşağıdaki belirli use case’ler için kullanılabilir.</p><ol><li><strong>Mesajlaşma: </strong>Çoğu mesajlaşma sistemine kıyasla Kafka, daha iyi verime, yerleşik bölümleme, çoğaltma ve hata toleransına sahiptir ve bu da onu büyük ölçekli mesaj işleme uygulamaları için iyi bir çözüm haline getirir.</li><li><strong>Web Sitesi Aktivite Takibi: </strong>Özellikle anlık analiz, makine öğrenmesi gibi işlemler için yoğun mesaj trafiğinde bile kabul edilebilir gecikmeye (latency) sahip işlemlere kullanılabilir.</li><li><strong>Metrikler: </strong>Genellikle operasyonel verileri izleme ve sistem durumu takibi için kullanılabilir.</li><li><strong>Log Aggregation: </strong>Uygulamaların, databaselerin ve bazı altyapı bileşenlerinin Kafka üzerinden log akışı sağlanıp aynı akış üzerinden bir çok connector aracılığı ile farklı veri saklama sistemlerinde (Elasticsearch, Hadoop, SQL Server) tutulabilmesini sağlar.</li><li><strong>Event Sourcing: </strong>Kafka, yüksek performanslı, düşük gecikme süreli, ölçeklenebilir ve dayanıklı bir veri akış sistemidir. Bu nedenle Kafka, olay kaynağı tabanlı bir uygulama mimarisine doğru ilerlerken olayları iletmek için kullanılabilecek avantajlı bir sistemdir.</li></ol><p><strong>Kafka’yı Hangi Büyük Firmalar Kullanıyor ?</strong></p><ul><li>Uber</li><li>Netflix</li><li>LinkedIn</li><li>Slack</li><li>Spotify</li><li>Shopify</li></ul><h3><strong>Örnek Proje</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b338283def4804b15d403b2734d5b1ad/href">https://medium.com/media/b338283def4804b15d403b2734d5b1ad/href</a></iframe><p>Yukarıdaki class’ımızın görevi belirli key ve value içeren mesajları producer aracılığı ile kafka broker’a göndermektir. Producer’ı oluştururken bazı konfigürasyon ayarları kullanmaktayız. Bunların açıklamaları aşağıda belirttiğim gibidir;</p><ul><li><strong>BootstrapServers</strong>: Kafka cluster’ına bağlandığımız broker adresidir. Cluster’daki her broker bir “bootstrap server” görevini gerçekleştirebilir.</li><li><strong>MessageMaxBytes: </strong>Gönderilicek olan mesajın olabilicek maksimum boyutunu belirttiğimiz parametredir.</li><li><strong>MessageTimeoutMs: </strong>Mesajın broker’a yazılmasını beklediğimiz, maksimum milisaniye cinsinden süredir<strong>.</strong></li><li><strong>Acks</strong>: Mesajların partition’a yazılma durumunun bildirilmesi için kullanılan parametredir. Parametrenin alabileceği 3 değer var bunlar;<br> — All: Producer mesajın leader ve replica partition’larına yazılmasını bekler. Yazılamadığı durumda hata fırlatılır.<br> — Leader: Producer mesajın sadece leader partition’nına yazılmasını bekler. Yazılamadığı durumda hata fırlatılır.<br> — None: Producer mesajın partition’a yazılıp yazılmadığı durumu kontrol etmez.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/269571b044bfcd9348305fc906618a9a/href">https://medium.com/media/269571b044bfcd9348305fc906618a9a/href</a></iframe><p>Yukarıdaki class’ımızın görevi mesajları consumer kullanarak kafka broker’daki partition’dan offset sırası ile okumaktır. Mesaj ile işimiz bittikten sonra mesajımızı commit’leyerek offset güncelleriz ve sıradaki mesajı okunmaya hazır hale gelir. Consumer’ı oluştururken bazı konfigürasyon ayarları kullanmaktayız. Bunların açıklamaları aşağıda belirttiğim gibidir;</p><ul><li><strong>BootstrapServers</strong>: Kafka cluster’ına bağlandığımız broker adresidir. Cluster’daki her broker bir “bootstrap server” görevini gerçekleştirebilir.</li><li><strong>MessageMaxBytes: </strong>Gönderilicek olan mesajın olabilicek maksimum boyutunu belirttiğimiz parametredir.</li><li><strong>SessionTimeout: </strong>Consumer’ın aktif olduğunu belirtmek için broker’a belirli aralıklar ile liveness mesajı gönderilmektedir, bu mesajların tanımladığımız süre boyunca gelmemesi durumunda consumer down olarak değerlendirilip partition’daki mesajlar başka bir consumer tarafından tüketilir.</li><li><strong>ClientId</strong>: İstekler yapılırken sunucuya iletilecek bir kimlik bilgisidir. Bunun amacı, sunucu tarafı istek günlüğüne mantıksal bir uygulama adının eklenmesine izin vererek isteklerin kaynağını sadece ip/port’un ötesinde izleyebilmektir.</li><li><strong>GroupId</strong>: Bu consumer’ın ait olduğu consumer grubunu tanımlayan benzersiz bir kimlik bilgisidir. Her consumer grubu için okuduğu partitionlar’ın offset’i saklanır. Aynı partition’ı farklı consumerlar için kullanmak istiyorsak bu partitionlar farklı gruba ait olmalıdır böylece farklı gruplardaki consumerlar farklı offsetleri kullanarak mesaj okuma işlemini gerçekleştirebileceklerdir.</li><li><strong>EnableAutoCommit</strong>: Eğer “true” ise, consumer’ın ofset’i arka planda periyodik olarak commit’lenicektir. Commit’lenme zaman aralığı default olarak 5000 milisaniyedir. Bu süre zarfında pod bir şekilde down olduğunda okunmuş mesajlar commit’lenmediği için offset güncellenmiyecek ve aslında okunmuş mesajlar tekrar okunmaya çalışılıcaktır buda hataya sebep olabilicek bir durumdur. O yüzden manuel olarak commit’leme işlemini gerçekleştiriyorum.</li><li><strong>AutoOffsetReset</strong>: Kafka’da başlangıç ​​ofseti olmadığında veya mevcut ofset sunucuda artık yok ise ne yapılması gerektiğini bu parametrede belirtiyoruz. Parametrenin alabileceği 3 değer var bunlar; <br> — <em>Earliest</em>: Partition’daki ilk mesajdan okunmaya başlanır ve ilk mesajın olduğu sıra offset olarak belirlenir. <br> — <em>Latest: </em>Partition’daki son mesajdan okunmaya başlanır ve son mesajın olduğu sıra offset olarak belirlenir.<em><br> — None: Consumer tarafından hata fırlatılır.</em></li></ul><p>Projenin kaynak kodlarına <a href="https://github.com/mertturkman/KafkaPubSubSample">burdan</a> erişebilirsiniz.</p><p>Elimden geldiğince anlaşılır şekilde anlatmaya çalıştım umarım faydalı olmuştur 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f2d4920450c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[gRPC, HTTP/2, Protocol Buffer teknolojilerini kullanarak servis geliştirilmesi]]></title>
            <link>https://medium.com/@mertturkman/grpc-http-2-protocol-buffer-teknolojilerini-kullanarak-servis-geli%C5%9Ftirilmesi-dcd31fa2920f?source=rss-f5f6fcbabf96------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcd31fa2920f</guid>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[protocol-buffers]]></category>
            <category><![CDATA[protobuf]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[http2]]></category>
            <dc:creator><![CDATA[Mert Türkman]]></dc:creator>
            <pubDate>Wed, 11 Aug 2021 11:11:17 GMT</pubDate>
            <atom:updated>2021-08-11T11:13:47.661Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba arkadaşlar, bu yazımda ana konum gRPC teknolojisi olucak, bununla beraber gRPC altyapısını oluşturan protocol buffer ve HTTP/2 teknolojilerini anlatacağım. Son olarak basit CRUD işlemlerini gerçekleştiren bir gRPC servis yapısını oluşturmuş olduğum örnek ile birlikte anlatıcam. Haydi başlayalım :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpZOFKC32_fkGfG3oj4MTw.jpeg" /></figure><h3>HTTP/2</h3><p><strong>HTTP/2</strong> (<strong>HTTP/2.0</strong>) Dünya Çapında Ağ Birliği (World Wide Web ) tarafından kullanılan HTTP ağ protokolünün ikinci ana sürümüdür. Chrome, Opera, Firefox, Internet Explorer 11, Safari ve Edge gibi bir çok tarayıcı tarafından standartlaştırılması desteklenmektedir. Çoğu ana tarayıcı 2015 yılı sonuna kadar HTTP/2 desteğini sağladı. Güvenlik endişeleri nedeni ile SSL/TLS gibi güvenlik katmanı olması tarayıcılar tarafından zorunlu kılınmıştır.</p><h3><strong>HTTP/2 Avantajları</strong></h3><ul><li>Multiplexing (Çoklama) yapısı, tek bir TCP bağlantısını kullanarak bu bağlantı üzerinden parallel olarak çok sayıda istek gönderebileceği şeklinde anlatabilirim.</li><li>İstemci bir istek yolladığında, sunucu tek bir TCP<strong> </strong>bağlantısı üzerinden aynı anda gerekli tüm statik dosyaları yanıt olarak döndürebilir buda bir çok durumda veri trafiğini azaltıcaktır.</li><li>Server push yapısı sunucunun, istemci talep etmeden kaynakları istemciye göndermesini sağlar. Çoğunlukla, kaynakları önceden yüklemede yardımcı olabilecek bir performans tekniğidir.</li><li>Header compression yapısı ile sayfaların header bilgileri sıkıştırılıcaktır. Dolayısıyla bu şekilde transfer edilen sayfa boyutları azalıcak.</li><li>Veriler eskiden olduğu gibi metin formatında değil binary formatta transfer edilicek ve bu yöntem ile verilerin daha hızlı transfer edilmesini sağlanıcaktır.</li></ul><h3>HTTP/2 Dezavantajları</h3><ul><li>Artık güvenli bağlantı (SSL,TLS) tarayıcılar tarafından kullanılmaya mecbur olduğu için, daha uzun gecikme süreleri yaşanıcaktır. Güvenli bir bağlantı daha fazla yük getirir.</li><li>HTTP/2 protokolünün en büyük eksisi geliştiriciler arasındaki güvenlik konusu ile ilgili anlaşmazlıklar. Mevcut bazı şifreleme yöntemlerininde uyumluluğu tartışma konusudur.</li><li>Server push özelliğinin dikkatli kullanılmaması aslında gerekenden daha fazla bant genişliğini boşa harcayabilir.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*5M1TSeYNHb1CSeZrifwJiA.png" /></figure><p>Örnek bir kafeye gittiğimizi düşünelim garsona sipariş veriyoruz sandviç, kola, baklava gibi peki bu istediklerimi tek tek getirip geri dönmesi mi mantıklı yoksa yoksa bir kez servis yapıp tüm ürünlerimi tek seferde getirmesi mi ? Garsonumuzu boşuna yormayalım :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*Qhr7sMIaWIwXj51E_GzZyQ.png" /></figure><p>Arkadaşlar yukarıdaki görüntüde belli olduğu gibi HTTP/1.1 protokolü kullanarak farklı bir çok istek ile cevap alabiliyoruz ama HTTP/2.0 protokolü ile bir bağlantı üzerinden bir çok paralel dönen cevaba erişebiliyoruz.</p><h3>Protocol Buffer</h3><p>Protocol buffer, yapılandırılmış verileri serileştirme yöntemidir. İlk olarak Google’da 2001 yılında kullanılmaya başlandı. Google tarafından 2015 yılında açık kaynak kodlu bir teknoloji haline getirildir. Google, kendi içindeki ihtiyaçlar için protocol buffer teknolojisini geliştirdi ve birden çok dil için destek sağladı. Bir ağ üzerinden birbirleriyle iletişim kuracak uygulamalar geliştirmede veya veri depolamada kullanışlıdır.</p><h3>Protocol Buffer Avantajları</h3><ul><li>Binary serialization yaptığı için makine diline daha yakındır bu yüzden yorumlama işlemi daha performanslı gerçekleşir.</li><li>Text formatlı standartlara (JSON, XML) nispeten daha az boyuta sahiptir.</li><li>Data modelleri için belirli bir şema yapısı mevcuttur. Bu yapı sayesinde veri transferinde data modellerinde şema uyumsuzluğu mevcut ise deserialization işleminde hata oluşucaktır böylelikle veri kaybı yaşanması önlenicektir.</li><li>Şemada field tanımlamadaki required, optional ve repeated anahtar sözcükleri ile validasyon işlemlerini gerçekleştirebilmemizi sağlar.</li><li>Bir çok yazılım dili tarafından destek verilmektedir.</li></ul><h3>Protocol Buffer Dezavantajları</h3><ul><li>Servisten alınan veriler doğrudan bir web tarayıcısı tarafından tüketilemez ancak offical olmayan bazı paketler ile bu sağlanabilir.</li><li>Transfer edilen veriler insan tarafından okunabilir değildir.</li><li>Debug işlemlerinde zorluk yaşanmasına sebep olması.</li><li>Data modellerini şema yapısına bağlamaya hazır olmak zorundadır.</li><li>Community desteği json kadar güçlü değil.</li></ul><h3>Performans Karşılaştırması</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rIqFQ4hIKcKoXvrPAf_uow.png" /></figure><p>Grafikte serialization ve deserialization işlemlerinin farklı standartlar ve paketler kullanılarak ne kadar sürdüğünü göstermektedir.</p><h3>gRPC</h3><p>gRPC (Remote Procedure Calls), 2015 yılında Google tarafından geliştirilen açık kaynaklı bir uzaktan prosedür çağrısı (RPC) teknolojisidir. HTTP/2 ve protocol buffer ile birlikte kullanılmaktadır. Bu teknolojiler sayesinde daha önce bahsetmiş olduğum binary serialization, multiplexing, server push, header compression gibi özellikleri gRPC ile birlikte kullanabiliyoruz. Desteklenen yazılım dilleri için servisler arası istemci ve sunucu bağlantıları oluşturur. Daha çok servisler arası veya mobil uygulamalar üzerinde veri iletişimi için uygun bir teknolojidir. Bunun nedeni browserler için mevcut bir official deserialization kütüphanesi olmamasıdır.</p><h3>gRPC VS RESTFUL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zl0uvXwF_9gVebgNJ5t-CQ.png" /></figure><p>Bu görsel gRPC ve Restful servis teknolojilerinin farklarını ana hatları ile özetlemektedir. Dikkat ederseniz daha önce burdaki bir çok özelliğe değinmiştik.</p><h3>gRPC Veri İletişim Şeması</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*17KCOlRK4Dm73tSLj9k-Qg.png" /></figure><p>Gördüğümüz gibi stub client HTTP/2 protokolü üzerinden protocol buffer standartı ile serialization işlemini gerçekleştirdiğimiz verileri server’a gönderiyor burda deserialization işlemi gerçekleştiriliyor ve işlem yapılabilir veriye dönüşüyoruz. Server’da işlem gerçekleştikten sonra cevabımızı serialize edip client’a gönderiyoruz ve client tarafından deserialize ettikten sonra kullanılabilir data halini alıyor. Burda önemli nokta protocol buffer şemasının aynı olması client-server arasında farklılık olması hataya yol açıcaktır.</p><h3>Örnek Proje</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5a9d596de71e9f3b140867b20e9aab7/href">https://medium.com/media/c5a9d596de71e9f3b140867b20e9aab7/href</a></iframe><p>Sipariş şeması, rpc servis tanımlamalarını oluşturup <strong>timestamp</strong> ve <strong>empty</strong> şemalarını import ettik bunlar “<strong>well known types” </strong>olarak bilinir. Bunun gibi bir çok şema tanımlamasına ve açıklamalarına <a href="https://developers.google.com/protocol-buffers/docs/reference/google.protobuf">burdan</a> erişebilirsiniz. Bazı servislerin geri dönüş tipi <strong>empty</strong> olarak tanımlıdır bunlar geriye herhangi bir veri döndürmeyen rpc metodudur.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ef1b4bf7d5176465087a1a87798d02f/href">https://medium.com/media/7ef1b4bf7d5176465087a1a87798d02f/href</a></iframe><p>Server tarafına CRUD isteklerini gönderebilmemiz için order stub client oluşturduk.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fdf83ae0dc19a73f9bb898376727a73/href">https://medium.com/media/3fdf83ae0dc19a73f9bb898376727a73/href</a></iframe><p>MongoDB veritabanını kullanarak CRUD işlemlerini gerçekleştiren gRPC servisimizi oluşturduk.</p><p>Projenin kaynak kodlarına <a href="https://github.com/mertturkman/ordergrpc">burdan</a> erişebilirsiniz.</p><p>Elimden geldiğince anlaşılır şekilde anlatmaya çalıştım umarım faydalı olmuştur :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcd31fa2920f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>