<?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"><channel><title><![CDATA[Osman Ödemis]]></title><description><![CDATA[AI
Software Development
Cloud Development
AWS
Amazon
Java
JavaScript
Frontend
Backend
Spring Boot
Quarkus
JPA]]></description><link>https://blog.oedemis.io</link><generator>RSS for Node</generator><lastBuildDate>Wed, 13 May 2026 21:17:06 GMT</lastBuildDate><atom:link href="https://blog.oedemis.io/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding LLMs: A Simple Guide to Large Language Models]]></title><description><![CDATA[Hello, passionate learners from around the world ✌️
In 2023 ChatGPT from OpenAI reached 100 million users faster than other solutions in Web 2.0 era.

Source: Yahoo Finance
And since then many intelligent models from Anthropic, Cohere, IBM, Goole, Am...]]></description><link>https://blog.oedemis.io/understanding-llms-a-simple-guide-to-large-language-models</link><guid isPermaLink="true">https://blog.oedemis.io/understanding-llms-a-simple-guide-to-large-language-models</guid><dc:creator><![CDATA[Osman Recai Ödemis]]></dc:creator><pubDate>Tue, 04 Mar 2025 11:18:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/slItfWbhijc/upload/370c9aa91156d2a97aef6fb96afc18a0.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello, passionate learners from around the world ✌️</p>
<p><strong>In 2023 ChatGPT from OpenAI reached 100 million users faster than other solutions in Web 2.0 era</strong>.</p>
<p><a target="_blank" href="https://businessday.ng/technology/article/chatgpt-is-fastest-app-to-hit-100m-users-in-history/"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740711074006/8b846e15-f1c9-4d75-8717-4c98f5090f19.png" alt class="image--center mx-auto" /></a></p>
<p>Source: <a target="_blank" href="https://s.yimg.com/ny/api/res/1.2/mFgKYoRAVYY.iM0W1bosWw--/YXBwaWQ9aGlnaGxhbmRlcjt3PTk2MDtoPTU0ODtjZj13ZWJw/https://media.zenfs.com/en/investorplace_417/88edce7bdb31a5c94ff3828c677cb0f7">Yahoo Finance</a></p>
<p>And since then many intelligent models from <strong>Anthropic, Cohere, IBM, Goole, Amazon, Meta AI, DeepSeek, HuggingFace</strong> come up and also many startups entering the arena. It’s interesting times to invest in our skillset.</p>
<p>Platforms like <a target="_blank" href="https://huggingface.co/">HuggingFace</a>—the GitHub of AI—serving as open hubs where an entire ecosystem of researchers and developers collaborate to share, fine-tune, and deploy AI models across the spectrum from natural language processing to computer vision. The scale is here 1.4 million models already deployed, with new breakthroughs arriving weekly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740710195334/4c492a31-09d5-4162-b912-a0d161ac40ce.png" alt class="image--center mx-auto" /></p>
<p>In this blog post, I will try to give a overview of the key components of <strong>Large Language Models (LLMs)</strong> at a high level, focusing on basic concepts, minimal math, and visual explanations to make complex ideas easy to understand.</p>
<h2 id="heading-why-this-actually-matters">Why This Actually Matters</h2>
<p>Understanding model architecture isn't just academic. Fine-tuning models, interpreting model cards, and selecting the right model for specific tasks like todays popular agentic architectures can imply the difference between breakthrough performance, costly failures and maybe also security vulnerabilities.</p>
<p>These models are reshaping how we work, learn, and create—right now. Whether you're an educator designing curriculum, a researcher, or simply curious about the technology transforming your daily life, invest in these fundamentals (I also put many resources at the end of the blog).</p>
<p>The technology feels like magic, let’s explore together! 🤗</p>
<h3 id="heading-the-road-to-generative-ai-key-milestones"><strong>The Road to Generative AI: Key Milestones</strong></h3>
<p>But first, lets start with a quick history of Artificial Intelligence. AI is a discipline with a vast history and many applications in the real world. Very inspiring development phase with amazing research and development breakthroughs. While AI encompasses many approaches, this guide focuses specifically on the architecture that's changing everything: <strong>Transformers</strong>. The true inflection point came in 2017 with the publication of a paper titled: <a target="_blank" href="https://arxiv.org/pdf/1706.03762"><strong>"Attention is all you need."</strong></a> The work by Vaswani and his friends would fundamentally transform AI capabilities and set the stage for today's generative revolution.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740766688660/597e8d90-00db-43c5-b24f-b3e3f82cfe5f.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-ai-language-modeling">AI Language Modeling</h1>
<p>Language models are fundamentally about understanding deep connections between words, concepts, and context—similar to how our own brains process language.</p>
<p>Imagine two friends chatting:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741025665870/b0dca83e-80c5-468e-ba73-4dc61cbb570a.png" alt class="image--center mx-auto" /></p>
<h4 id="heading-person-1-speaking"><strong>Person 1 (speaking):</strong></h4>
<p><em>"Last night, I was in the</em> <strong><em>studio</em></strong>*, working on a* <strong><em>new track</em></strong>*, tweaking the* <strong><em>melody</em></strong>*, and then I realized I needed to* <strong><em>adjust</em></strong> <em>my..."</em></p>
<p>At this moment, <strong>Person 1 own thought process is already being pulled</strong> toward a specific word before they even say it. Their mind is influenced by the words they just used—<em>"studio," "track," "melody,"</em> and <em>"adjust"</em>—making <strong>"keyboard</strong> 🎹**"** feel like the most natural next word.</p>
<h4 id="heading-person-2-listening"><strong>Person 2 (listening):</strong></h4>
<p>As Person 1 speaks, <strong>Person 2 is in thinking/listening mode,</strong> but what Person 2 expects depends on both Person 1’s words and their own <strong>mental associations</strong>. Person 2’s <strong>interpretation is influenced by Person 1’s context</strong> 🎹**.**</p>
<p>Just like in LLM’s, <strong>similarity helps pull related concepts together—such as how "melody" and "track" reinforce the idea of music—while attention helps focus on the most relevant words, filtering out less important information to determine meaning.</strong></p>
<h2 id="heading-the-secret-sauce-of-llms-similarity-attention">The Secret Sauce of LLMs: Similarity + Attention</h2>
<p>This human conversation mirrors how LLMs work:</p>
<ul>
<li><p><strong>Similarity</strong> creates connections between related concepts—just as "melody" and "track" naturally point toward music-related completions.</p>
</li>
<li><p><strong>Attention</strong> helps filter out noise and focus on what matters most—determining which earlier words are most important for predicting what comes next.</p>
</li>
</ul>
<h2 id="heading-next-word-prediction-the-core-task">Next-Word Prediction: The Core Task</h2>
<p>Like the example with above, at its heart, a Large Language Model has one fundamental job: <strong>"next token prediction."</strong></p>
<p>These sophisticated systems learn patterns from massive datasets to predict the next token in a sequence. When you type <strong><em>"Which move in AlphaGo was surprising?"</em></strong> the model:</p>
<ol>
<li><p>Processes your prompt</p>
</li>
<li><p>Calculates probabilities for every possible next token</p>
</li>
<li><p>Selects the most likely continuation (or samples from high-probability options)</p>
</li>
<li><p>Repeats until it reaches a natural stopping point</p>
</li>
</ol>
<p>The process continues word by word until the model decides to end the sequence, producing something like: <strong><em>"The most surprising move was 37"</em></strong></p>
<p>This simple mechanism—predicting one token at a time based on everything that came before—is the foundation for Large Language models, that can now write essays, code, stories, and even simulate conversations.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740760807533/067ad41b-3d3d-48ea-be3b-b392ecbdb038.png" alt class="image--center mx-auto" /></p>
<p>The complete sequence goes on, until the LLM decides, to bring a special token like <strong>|EOS| <em>“End of Sequence”</em></strong> and the answer ends with <strong><em>“The most surprising move was 37”</em></strong> like.</p>
<p><em>The complete flow illustrated:</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740760933389/83892179-0178-48f3-8aab-592473ea84b7.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740761108922/72f11153-509d-4d6c-8512-aa3d97fdd75f.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741034171199/b4466451-5344-4764-b91f-490defc85abb.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-journey-to-an-llm-artifact">The Journey to an LLM artifact</h2>
<p>We can imagine these models as a compressed ZIP file of internet data. It contains the so-called million or billion parameter weights (floating-point numbers), which during training are adjusted and learned.</p>
<p><img src="https://thumbs.static-thomann.de/thumb//thumb580x/pics/cms/image/guide/de/dj_systeme/fotolia_11356585_subscription_xl.jpg" alt="Das DJ-ing – Musikhaus Thomann" /></p>
<p>To achieve such behavior, we require high-quality data, substantial computational power, memory, and extensive GPU clusters. Training these models is costly and time-consuming, often taking months. Not many companies can afford the millions of dollars needed to train a model from scratch.</p>
<p>For example, <a target="_blank" href="https://blogs.nvidia.com/blog/meta-llama3-inference-acceleration/">Llama 3</a> from Meta AI was trained on 24,576 GPU clusters for months, and Meta's <a target="_blank" href="https://www.wired.com/story/meta-llama-ai-gpu-training">Llama 4</a> is currently being trained on a cluster exceeding <strong>100,000 NVIDIA H100 GPUs</strong>. DeepSeek R1 model is trained on a smaller set of GPUs but uses advanced architecture training, which I want to explain in further blog posts, called Reinforcement Learning. This huge computational requirement also raises sustainability concerns, one of the most important topics in training models. A very good session about GPU power consumption is available at the <a target="_blank" href="https://media.ccc.de/v/38c3-resource-consumption-of-ai-degrow-or-die">CCC</a>.</p>
<p><img src="https://www.fibermall.com/blog/wp-content/uploads/2024/07/5.4-1.png" alt="Das Potenzial von GPU-Clustern für fortgeschrittenes maschinelles Lernen  und Deep Learning-Anwendungen freisetzen - fibermall.com" /></p>
<p>Let's take a quick journey through these training steps.</p>
<h2 id="heading-data-preparation">Data preparation</h2>
<p>Large Language Models are trained on a massive scale of internet data. I mean by large scale, trillions and billions of tokens. In the upcoming sections I'll explain more about tokens. At the same time, we want large diversity and high-quality documents. One popular dataset is CommonCrawl. Common Crawl, a non-profit organization, has been crawling the web since 2007, and actually contains 2.7 billion web pages. If you are interested in a large scale data pipeline and a cleaned up dataset, look at the <a target="_blank" href="https://github.com/huggingface/fineweb-2">FineWeb</a> project from HuggingFace.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740723067563/c150dded-dee9-40af-9ae5-e661d75f1f1e.png" alt="steps taken to produce FineWeb dataset for LLM training" class="image--center mx-auto" /></p>
<p><strong><em>steps taken to produce FineWeb dataset for LLM training</em></strong></p>
<p>I don't want to go into the details of data engineering in this post, as it is about LLM concepts, but remember it's trained on large diversity and high quality of data. To see the full pipeline visit FineWeb. Also worth mentioning you can explore some public datasets on <a target="_blank" href="http://atlas.nomic.ai">atlas.nomic.ai</a> and the diversity of the topics covered in the domains. Also <a target="_blank" href="https://huggingface.co/docs/datasets/index">HuggingFace Dataset</a> is a good source to discover more datasets.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740770924442/ef4a169e-bdea-493e-848a-95ee7002641e.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-from-base-models-to-chat-assistants">From Base Models to Chat Assistants</h2>
<p>Next, we train a model for next token prediction. These models are also called <strong>base models</strong>, and their names typically end with <strong><em>"Base"</em></strong>, like <strong>Llama-3.1-405B-Base</strong>.</p>
<p>However, these base models do not behave like ChatGPT or instruction-tuned models (e.g., <strong>Llama-3.1-405B-Instruct</strong>) that we experience through web interfaces.</p>
<p>The base models are just the foundation - they can predict token incredibly well but lack the refined conversational abilities of the instruction-tuned versions that power consumer-facing AI assistants.</p>
<p>For example if we prompt <strong>Llama-3.1-405B-Base</strong> with:</p>
<p><strong><em>Prompt: "Which move in AlphaGo was surprising?</em></strong></p>
<p>we get following <strong><em>response sequence</em></strong>:</p>
<p><strong><em>“Is it possible to explain it?" The following is a question I posed to the AlphaGo team, as part of an academic project: Which move in AlphaGo was surprising? Is it possible to explain it? AlphaGo's moves are often surprising to human players, as they are based on a deep understanding of the game that is difficult for humans to replicate. One example of a surprising move made by AlphaGo…..”</em></strong></p>
<p>The base model artifacts are produced during the most costly phase: pre-training.</p>
<p><strong><mark>BUT: This is not what we want from an model. Most of the time we're summarizing papers, translating sections, or generating content based on user questions or prompts.</mark></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740764750636/3c69810f-8ad5-480e-951e-04ad02cd33cb.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-instruction-tuning">Instruction Tuning</h2>
<p>In order to get an assistant model like GPT, we need to <strong>align</strong> our model for our downstream task, which is awesome. For example, we can align to <strong>question answering, classification, translation, different persona roles that the model can take, topic modeling, clustering</strong> etc. The list goes on throughout the NLP journey.</p>
<p>Think of it as following: you are giving a task for factual label checking, and we need to create thousands of instruction pairs. Then taking thousands of this possible pairs we can further fine-tune our base model and get an instruction tuned model. <a target="_blank" href="https://www.youtube.com/watch?v=7xTGNNLPyMI">Andrej Karpathy</a> explanations is very good.</p>
<h3 id="heading-these-instruction-pairs-look-like-this-factual-explanation">These instruction pairs look like this: Factual Explanation</h3>
<p><strong>Instruction<em>: Explain how photosynthesis works in simple terms.</em></strong></p>
<p><strong>Response labeled<em>: Photosynthesis is how plants make their food. They take sunlight, water, and carbon dioxide from the air and convert it into oxygen and glucose (sugar). This happens in tiny structures called chloroplasts, which contain chlorophyll—the green pigment that captures sunlight energy. Plants use the glucose for energy and to build structures like stems and leaves. The oxygen is released into the air for us to breathe.</em></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740764810094/c9891acc-d2af-492b-86b9-a07c3340c211.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-beyond-instruction-tuning">Beyond Instruction Tuning</h2>
<p>These data can be created from humans or synthetic data generation. But the story doesn't end here—we need further improvements. Reinforcement Learning or Reinforcement Learning from Human Feedback like OpenAI approaches makes the alignment better.</p>
<h2 id="heading-reinforcement-learning">Reinforcement Learning</h2>
<p>Reinforcement learning is an amazing field of artificial intelligence. We've heard in the news about breakthroughs from DeepSeek's <strong>pure RL approach</strong>. Let's illustrate RLHF or so-called Reinforcement Learning from Human Feedback simply.</p>
<p>Initially, an instruction-tuned model is trained to follow prompts, but it undergoes further fine-tuning through reinforcement learning. During this phase, models interact with prompts, learn from trial and error, and receive human feedback to align responses with user expectations. This iterative process helps LLMs improve accuracy, relevance, and coherence, making them more effective in real-world applications.</p>
<h3 id="heading-the-reward-model-in-rlhf">The Reward Model in RLHF</h3>
<p>The reward model's job is surprisingly simple: it just assigns a numerical score to any response. For example, when the LLM generates multiple answers to <strong>"Explain climate change"</strong> the reward model might give a <strong>score</strong> of 8.7 to a clear, accurate explanation and 3.2 to a confusing or inaccurate one. These scores then guide the learning process—the LLM is adjusted to maximize these reward scores, essentially learning to produce responses that humans would rate highly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740767683900/e46a8523-8655-4bb7-a516-3cc681e0e6e2.png" alt class="image--center mx-auto" /></p>
<p>Ok lets go further, until now we understand at a very high level, what is AI Language modeling, what’s the task of an training (next token prediction), how different models created. But let’s see the revolutionized Idea of Attention.</p>
<h1 id="heading-attention-is-all-you-need"><strong>Attention is all you need</strong></h1>
<p>In order to decode and process language in computers, we need a notion of:</p>
<ul>
<li><h3 id="heading-numbers-converting-language-to-numbers-also-called-embedding-space"><strong>Numbers - converting language to numbers also called embedding space</strong></h3>
</li>
<li><h3 id="heading-similarity"><strong>Similarity</strong></h3>
</li>
<li><h3 id="heading-attention"><strong>Attention</strong></h3>
</li>
</ul>
<h1 id="heading-tokenizer-the-first-gateway-to-llms">Tokenizer: The First Gateway to LLMs</h1>
<p>This is the first step whenever we interact with an LLM like ChatGPT, Claude or any LLM API. Imagine this as the LLM's <strong>Vocabulary</strong>. Every time we send a model a prompt, it first gets tokenized.</p>
<p><strong>Why?</strong> Because we need a <strong>mapping from text to numerical representations</strong> that computers can process and tokenization is the first part on the way <a target="_blank" href="https://emojiterra.com/motorway/">🛣️ 🛣️</a> Almost all of the model providers also have a pricing model based on consumed and output tokens.</p>
<p>Lets say you send ChatGPT the prompt <strong><em>“What is tokenization why we need this”.</em></strong> The prompt gets broken into colored tokens as shown in the image. Importantly, tokens don't always align with complete words—<strong>"token" &amp; "ization"</strong> are separated into different tokens.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740714880256/71c63de5-67e3-45fc-b124-d72c926a6ee7.png" alt class="image--center mx-auto" /></p>
<p><em>You can visually explore tokenization processes using tools like the</em> <a target="_blank" href="https://tiktokenizer.vercel.app/"><em>https://tiktokenizer.vercel.app/</em></a><em>.</em></p>
<h2 id="heading-why-use-subword-and-not-word-by-word">Why use subword and not word by word?</h2>
<p>Language is indeed complex and diverse, with new words constantly emerging across various languages. Many languages allows for the creation of new words from existing ones (e.g. sunflower), and some languages have even no spaces like Japanese (e.g. 今日はサーフィンに行きます). So our language models need to be generative and capable of capturing many patterns. Building a vocabulary with millions of words is not effective and even not possible.</p>
<p>Tokenizers are algorithms that capture statistical properties of large text corpora on which LLMs are pre-trained. There are different techniques for tokenization, like <strong>BPE (Byte Pair Encoding), WordPiece, SentencePiece. In this post I don't go inside, but assume with tokenizers we get an intelligent vocabulary with subword tokens from our corpus of data.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740770601754/5624bc0c-b0a8-4a20-8b64-5c0d17b5b0a6.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-first-numbers-position-ids-to-token-embedding-vectors">First numbers: Position IDs to token embedding vectors</h2>
<p>Remember tokenizer creates our vocabulary and helps us <strong>mapping from text to numerical representations.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740770719555/b5ad0ef2-831f-49fd-b132-53b84238cf52.png" alt class="image--center mx-auto" /></p>
<p>In general tokens can be anything from words, image patches, speech segments which has an <strong>ordered sequence</strong> in the nature. In the above example <strong><em>"What a wonderful world."</em></strong> is mapped to the numbers <strong>4827, 261, 10469, 2375, 13</strong> and so on called the Position IDs. These IDs are encoded in the model's inner architecture (<strong>Embedding-Matrix</strong>) and maps our tokens to a <strong>fixed</strong> token embedding vector.</p>
<p>But why <strong>Positons IDs</strong> are so important?, because language is ordered and we should keep track of order for each token later in processing, for example most phenomena in the nature are ordered most not. Imagine machine translation, words can take another position in a sequence.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740771753260/0145ee2c-fda7-4fa7-bbe7-a3313a79af17.png" alt class="image--center mx-auto" /></p>
<p>From these ID's we get fixed vectors, so called token embedding vectors. These embedding vectors has huge dimension for example in <a target="_blank" href="https://huggingface.co/ibm-granite/granite-3.1-8b-instruct">ibm-granite/granite-3.1-8b-instruct</a> LLM has <strong>4096</strong> dimension size.</p>
<h1 id="heading-its-all-about-similarity">It's all about similarity?</h1>
<p>Ok tokenizer, position ids, and what are these token embedding vectors?</p>
<p>We need this because, with the power of linear algebra we can apply mathematical operations. Let's explore these concepts in two dimensions for visualization :)</p>
<h3 id="heading-notion-of-similarity"><strong>Notion of similarity</strong></h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740772867859/3ffb55dc-1d22-450c-b668-99bab6625f74.png" alt class="image--center mx-auto" /></p>
<p>In this embedding space, we can see how words or concepts are arranged based on their meaning. The angle between vectors tells us how similar they are - smaller angles mean greater similarity. This is measured using <a target="_blank" href="https://en.wikipedia.org/wiki/Cosine_similarity"><strong>cosine similarity</strong></a>, which ranges from <strong>-1 (completely opposite) to 1 (identical).</strong> For example, the apple and orange vectors have a small angle between them, indicating high similarity, while the phone and fruits have a much larger angle, showing they're less related.</p>
<h2 id="heading-now-we-have-our-embeddings-and-calculate-similarity-between-the-embeddings-are-we-done">Now we have our embeddings and calculate similarity between the embeddings, are we done?</h2>
<p>Unfortunately not. These token embedding vectors are not perfect, and should be learned and adjusted during training, because language is all about context.</p>
<h2 id="heading-the-context-challenge-when-apple-isnt-just-a-fruit">The Context Challenge: When "Apple" Isn't Just a Fruit</h2>
<p>Imagine these situations, how the token embedding for <strong><em>“apple”</em></strong> should be calculated?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740773270580/8b94271c-c175-41bc-bb86-13637aef9c0e.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-the-problem-finding-the-right-embedding"><strong>The Problem: Finding the Right Embedding</strong></h3>
<p>The challenge is that we <strong>cannot assign a perfect place</strong> for every token in the latent space. Raw embeddings might capture <strong>some relationships</strong>, but they are often <strong>not well-aligned</strong> with real-world structures. To fix this, we apply <strong>linear transformations</strong>, which allow us to <strong>adjust the embedding space</strong> to better reflect similarities and relationships.</p>
<h1 id="heading-linear-transformations"><strong>Linear Transformations</strong></h1>
<p>So, what are <strong>linear transformations</strong>? Think of them as <strong>matrix operations</strong> applied to vectors. These operations can:</p>
<ul>
<li><p><strong>Stretch</strong> the space to emphasize certain dimensions 📏</p>
</li>
<li><p><strong>Rotate</strong> vectors to better align with meaningful directions 🔄</p>
</li>
<li><p><strong>Shear</strong> data to adjust relationships between points 📐</p>
</li>
<li><p><strong>Combine</strong> all these effects to create a better-structured space</p>
</li>
</ul>
<h2 id="heading-adjusting-embeddings-and-choosing-the-best-embedding"><strong>Adjusting Embeddings and Choosing the Best Embedding?</strong></h2>
<p>Imagine we want to discover the optimal embedding space that captures the true relationships in our data. Let's explore this with a simple example:</p>
<ul>
<li><p><strong>Ahmet</strong> is an excellent <strong>basketball player</strong> 🏀—he is great at <strong>jumping, agility, and teamwork</strong>.</p>
</li>
<li><p><strong>Sofia</strong> is a <strong>strong swimmer</strong> 🏊‍♂️—she excels in <strong>endurance and breathing control</strong>.</p>
</li>
</ul>
<p>Looking at the three embedding spaces below, we can immediately see why <strong>Embedding 3 is better</strong>. It organizes both athletes in relation to their sports while capturing their shared identity as <strong>athletes</strong>. During the training the so called the <strong>Multi-Head Attention Layer</strong> decides which Embedding is the best or combines them.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740777927121/2b79d5c9-cbe1-4f11-a370-36b800fe5bda.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-transformation-magic">Transformation Magic</h2>
<p>If we decide <strong>Embedding 3</strong> should be used then we apply a linear transformation with matrix. The values of the matrix is the <strong>learnable parameters.</strong> We're performing <strong>matrix-vector multiplication</strong>, which is calculated using multiple <a target="_blank" href="https://www.mathsisfun.com/algebra/vectors-dot-product.html">dot products</a>.</p>
<p>This process mirrors how our own brains might reorganize concepts—shifting from thinking about "sports equipment" to thinking about "athletes and their specialties" when the <strong>context</strong> requires it. The difference is that our AI models must learn these transformations through millions of examples rather than through lived experience.</p>
<p>The beauty of this approach is that as the model encounters more data, these transformation matrices continuously refine, creating increasingly nuanced understanding of the relationships between concepts.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740778452271/632bd158-814b-4d52-9f7f-48a4b5d3c01b.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-the-magic-of-attention-why-context-changes-everything">The Magic of Attention: Why Context Changes Everything</h1>
<p>Until now we've explored similarity (cosine, dot-product) and how linear transformations can create better embeddings. But we're missing something crucial - <strong>Attention</strong>, the breakthrough that revolutionized AI language understanding.</p>
<p>Let’s take a example—<strong>journalist</strong> and <strong>microphone</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740780420030/761f25f6-8746-4781-9347-a58b5bdbd062.png" alt class="image--center mx-auto" /></p>
<p>In an ideal world, these two should have a balanced connection in the embedding space, but in real-world <strong>training data</strong>, that’s not the case. <strong>A journalist strongly pulls "microphone"</strong>, but <strong>"microphone" does not strongly pull "journalist"</strong>.</p>
<h2 id="heading-why-this-asymmetry-exists">Why This Asymmetry Exists?</h2>
<p>Because in <strong>real-world data</strong>, "<em>journalist</em>" often appears with words like <strong>interview, report, article, media</strong>, and yes, <strong>microphone</strong>. But "<em>microphone</em>" has a much broader range—it appears with <strong>singers, podcasters, radio hosts, studio equipment, speakers</strong>, and many other unrelated concepts. So, when we ask:</p>
<ul>
<li><p><strong>"What does journalist relate to?"</strong> → <strong>Microphone is a strong association</strong> because journalists frequently use microphones.</p>
</li>
<li><p><strong>"What does microphone relate to?"</strong> → <strong>Journalist is a weak association</strong> because a microphone is used by many professions, not just journalists.</p>
</li>
</ul>
<h3 id="heading-why-a-single-linear-transformation-doesnt-work"><strong>Why a Single Linear Transformation Doesn't Work</strong></h3>
<p>If we apply <strong>only one transformation</strong>, we still get a <strong>symmetric pull</strong>, meaning the model would think that:</p>
<ul>
<li><p>"<em>Microphone</em>" should influence "<em>journalist</em>" just as much as "<em>journalist</em>" influences "<em>microphone</em>."</p>
</li>
<li><p>This is incorrect because a <strong>microphone is just a tool</strong>, and many people use it beyond journalists.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740781490760/8920277d-c9b7-4763-a3aa-8ae9165e5219.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-the-fix-two-linear-transformations"><strong>The Fix: Two Linear Transformations</strong></h3>
<p>To properly capture this, we need <strong>two different transformations</strong>. Lets introduce <strong>Key and Query</strong>. <strong>Key</strong> is which <strong>pulls</strong> the other token, and <strong>Query</strong> is which is <strong>pulled</strong>. We apply <strong>different perspectives</strong> depending on whether "<em>journalist</em>" or "<em>microphone</em>" is acting as the <strong>key</strong> or the <strong>query.</strong></p>
<ol>
<li><p><strong>Journalist (Key)</strong> – It <strong>strongly pulls</strong> "<em>microphone</em>" (Query) because it's an important tool for their work.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741030682811/aa54f616-f300-490b-a895-9e0d9d9308db.png" alt class="image--center mx-auto" /></p>
</li>
<li><p><strong>Microphone (Key)</strong> – It <strong>weakly pulls</strong> "<em>journalist</em>" because its use is much broader.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741030607142/f13af24f-c18e-468c-b936-85200e43bbe1.png" alt class="image--center mx-auto" /></p>
</li>
</ol>
<p><strong>The Formula</strong></p>
<p>Applying two linear transformations on Keys and Queries and then we take the angle between keys and queries. After that we can calculate the similarity via dot-product (the <strong>Attention matrix</strong>).</p>
<p><strong>Journalist (Key)</strong> – <strong>Microphone (Query) we want large cosine in similarity (strong pull).</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741078051940/9ade4d42-2c1a-4610-b52e-a5a894a50615.png" alt class="image--center mx-auto" /></p>
<p><strong>Microphone (Key)</strong> – <strong>Journalist (Query) we want small cosine in similarity (weak pull).</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741078016420/f0e27259-d9b9-43b8-9a73-70cb15e79af6.png" alt class="image--center mx-auto" /></p>
<p>Every value of this matrices is adjusted during training time, so we get a clearer embedding.</p>
<h2 id="heading-understanding-the-dot-product-in-attention">Understanding the Dot Product in Attention</h2>
<p>The dot product is the mathematical operation that powers attention. In simple terms:</p>
<ol>
<li><p><strong>What it does</strong>: Measures how aligned two vectors are with each other.</p>
</li>
<li><p><strong>How it works</strong>: Multiplies corresponding elements of two vectors and sums the results.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740784302066/f0c32506-ebad-4dbc-b055-8dbcaa626214.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-value">The Value</h2>
<p>But last, there is another component called <strong>Value</strong>. Think like this, the <strong>actual audio content</strong> captured by the microphone—it carries the <strong>real meaning</strong> the journalist wants to process. After computing the similarity between queries and keys (<strong>dot product of Q and K</strong>), these attention scores are used to <strong>weight the Values (V)</strong>. This means that:</p>
<ul>
<li><p>If <strong>a key strongly matches a query</strong>, its corresponding <strong>value is given more importance</strong>.</p>
</li>
<li><p>If <strong>a key weakly matches a query</strong>, its value contributes <strong>less to the final output</strong>.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740784428829/e8950908-df2a-432a-9da4-346f2a4e9f79.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-recap-we-are-extracting-from-an-token-embedding-the-query-key-and-values-based-on-this-trained-matrices-and-producing-a-more-contextualized-token-embedding-with-same-dimension"><strong>Recap:</strong> We are extracting from an token embedding the Query, Key and Values based on this trained matrices, and producing a more contextualized token embedding with same dimension</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741032805869/f975520c-bc4a-4c4c-804d-7133839c9980.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741079642864/c77926c7-f846-4bfb-a046-abd628f74d24.png" alt class="image--center mx-auto" /></p>
<p>  <strong>Token embeddings</strong> transform words into number vectors, creating a mathematical language.</p>
</li>
<li><p><strong>Linear transformations</strong> are the key mathematical operations that create the three different perspectives:</p>
<ul>
<li><p><strong>Each embedding is multiplied by three different matrices</strong> to create <strong>Query, Key, and Value</strong> representations of the same token</p>
</li>
<li><p>This is how one word can have multiple <strong>"views" or "roles" in the attention process</strong></p>
</li>
</ul>
</li>
<li><p><strong>Query perspective</strong> (Q matrix transformation): "What am I looking for in other words?"</p>
</li>
<li><p><strong>Key perspective</strong> (K matrix transformation): "What aspect of me might others find relevant?"</p>
</li>
<li><p><strong>Value perspective</strong> (V matrix transformation): "What information should I contribute if matched?"</p>
</li>
<li><p><strong>Same input, three views</strong>: The word "apple" starts as one embedding but is transformed into:</p>
<ul>
<li><p>A Query vector (searching for relevant information)</p>
</li>
<li><p>A Key vector (advertising what it contains)</p>
</li>
<li><p>A Value vector (the actual information to be used)</p>
</li>
</ul>
</li>
<li><p><strong>Dot products</strong> between queries and keys measure relationship strength, creating the attention map.</p>
</li>
<li><p><strong>Context-sensitive understanding</strong>: These transformations allow the model to interpret "apple" differently when it appears near "iPhone" versus "orchard."</p>
</li>
<li><p><strong>Asymmetric relationships</strong> are naturally modeled because each token has these three distinct roles.</p>
</li>
<li><p><strong>Multi-head attention</strong> applies multiple sets of these transformations in parallel, capturing different relationship types simultaneously.</p>
</li>
</ul>
<h2 id="heading-multi-head-attention-linear"><strong>Multi-Head-Attention (Linear)</strong></h2>
<p>One point, as we saw we need to combine between best embeddings, this is done via <strong>Multi-Head-Attention (Linear)</strong>. Below, from the original paper. Imagine these as an intelligent brain which combines the best token embedding based on context. Suppose many brains which are calculating embeddings and choose or combine and weight them based on context.</p>
<p><strong>Multiple attention mechanisms in parallel</strong>: Each "head" learns to focus on different aspects of language.</p>
<p><strong>The Linear transformations</strong>:</p>
<ul>
<li><ul>
<li><p><strong>Lower Linear layers</strong>: Project input embeddings into different "perspective spaces" - one might focus on syntax, another on semantics, another on entity relationships.</p>
<ul>
<li><strong>Upper Linear layer</strong>: Combines these multiple perspectives into a unified representation.</li>
</ul>
</li>
</ul>
</li>
</ul>
<p><strong>Scaled Dot-Product Attention</strong>: Each head calculates its own attention pattern based on its specialized Query, Key, Value projections.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740783716616/ef0251d4-3620-4223-97ee-fd71020afed2.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741033204630/6d798490-7369-4107-bab8-ce31d6e028d9.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-are-we-done-with-predicting-the-next-token">Are we done with predicting the next token?</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741081032532/30d105fd-4f28-4056-87f6-fbd97081df9e.png" alt class="image--center mx-auto" /></p>
<p>Until now, we have explored the attention mechanism. To predict the next token, the contextualized token embeddings pass through a multi-layer perceptron neural network (MLP) or a feedforward neural network (FFNN).</p>
<p>Unlike self-attention, which connects and applies attention to tokens, this process handles each token position separately. As the information flows through this sequence, the model refines its understanding of the relationships and meanings within the text. At this layer, the model generalizes the learned concepts. This is also where most of the model’s parameters reside.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741085630752/7f493b81-0e6f-4bd5-9f4a-ce633b397ac3.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-reading-a-model-card"><strong>Reading a model card</strong></h2>
<p>Some model parameters from <a target="_blank" href="https://huggingface.co/ibm-granite/granite-3.1-8b-instruct">ibm-granite/granite-3.1-8b-instruct</a></p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Model</strong></td><td><strong>8b Dense</strong></td><td>Explanation</td></tr>
</thead>
<tbody>
<tr>
<td>Embedding Size</td><td>4096</td><td>each token embedding dimension, which flows through the network</td></tr>
<tr>
<td>Number of layers</td><td>40</td><td>40 Transformer blocks</td></tr>
<tr>
<td>Attention head size</td><td>128</td><td>each attention head is 128 dimensions, 4096 = 32×128</td></tr>
<tr>
<td>Number of attention heads</td><td>32</td><td>32 heads in Attention</td></tr>
<tr>
<td>Number of KV heads</td><td>8</td><td>Key-Value projection pairs that are shared across multiple attention heads</td></tr>
<tr>
<td>MLP hidden size</td><td>12800</td><td>hidden layer in MLP or FNN</td></tr>
<tr>
<td>Sequence length (context window)</td><td>128k</td><td>Maximum process token embeddings at a time</td></tr>
<tr>
<td># Parameters</td><td>8.1B</td><td>total params</td></tr>
<tr>
<td># Training tokens</td><td>12T</td><td>12 trillion training tokens</td></tr>
</tbody>
</table>
</div><h2 id="heading-embedding-size-of-4096-and-number-of-layers-40"><strong>Embedding Size of 4096 and Number of Layers 40</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741084879125/66ee3904-0469-46c8-9e20-86870d3a4435.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-number-of-attention-heads-32-and-number-of-keyvalue-heads-8"><strong>Number of attention heads 32 and Number of Key/Value heads 8</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741085035143/5d54d8cb-45d1-4bcd-8289-a57f1cd53d5e.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-feedforward-neural-network"><strong>Feedforward Neural Network</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741085311872/202c1535-c000-4ea9-80ce-7a3f7ba802bf.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>We've journeyed through the inner workings of Large Language Models, uncovering the elegant concepts that enables machines to understand and generate human language. Through our exploration, we learned</p>
<ul>
<li><p><strong>The core training objective</strong> is surprisingly simple: predict the next token</p>
</li>
<li><p>Embeddings</p>
</li>
<li><p>Attention mechanism</p>
</li>
<li><p>Multi-head attention</p>
</li>
<li><p>Transformer architecture core components</p>
</li>
</ul>
<h1 id="heading-resources">Resources</h1>
<p>There is a lot to cover for more advanced deep dive I can suggest following resources.</p>
<p><a target="_blank" href="https://www.youtube.com/watch?v=RFdb2rKAqFw">https://www.youtube.com/watch?v=RFdb2rKAqFw</a></p>
<p><a target="_blank" href="https://www.youtube.com/watch?v=7xTGNNLPyMI">https://www.youtube.com/watch?v=7xTGNNLPyMI</a></p>
<p><a target="_blank" href="https://tirsus.com/tirsus-online-magazin">AI Academy which provides very good insights</a></p>
<p><a target="_blank" href="https://www.deeplearning.ai/short-courses/how-transformer-llms-work/">DeepLearning.AI</a></p>
<p><a target="_blank" href="https://www.llm-book.com/"><strong>Hands-On Large Language Models: Language Understanding and Generation</strong></a></p>
<p><a target="_blank" href="https://www.amazon.de/Praxiseinstieg-Large-Language-Models-Strategien/dp/3960092407/ref=sr_1_1?__mk_de_DE=%C3%85M%C3%85%C5%BD%C3%95%C3%91&amp;crid=14XFZB51JSEJZ&amp;dib=eyJ2IjoiMSJ9.tC2WNEzIw7ejUXPaF2AsCdvVeZ3BKM1WAVOozarynDUgs3tOppeOJSmt75ce3W1y.5XiatPATNtpf23LKSB0v5fvq2CSrmEos8CXZNJY1c2s&amp;dib_tag=se&amp;keywords=Praxiseinstieg+Large+Language+Models&amp;qid=1741033331&amp;sprefix=%2Caps%2C127&amp;sr=8-1">Praxiseinstieg Large Language Models: Strategien und Best Practices für den Einsatz von ChatGPT und anderen LLMs (available also in english)</a></p>
]]></content:encoded></item><item><title><![CDATA[Have Fun with AWS PartyRock]]></title><description><![CDATA[Hello folks, hope you are well 👋
Amazon recently launched PartyRock. It's really fun to play with and at the same time also opens up opportunities for everyone to create apps and experiment with LLMs. This includes experimenting with various foundat...]]></description><link>https://blog.oedemis.io/have-fun-with-aws-partyrock</link><guid isPermaLink="true">https://blog.oedemis.io/have-fun-with-aws-partyrock</guid><category><![CDATA[AWS]]></category><category><![CDATA[Artificial Intelligence]]></category><category><![CDATA[generative ai]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Osman Recai Ödemis]]></dc:creator><pubDate>Tue, 21 Nov 2023 00:39:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1700526971791/72f14a0a-96c4-4bb6-8523-9a057b5fb225.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello folks, hope you are well 👋</p>
<p>Amazon recently launched PartyRock. It's really fun to play with and at the same time also opens up opportunities for everyone to create apps and experiment with LLMs. This includes experimenting with various foundational models, understanding text-based prompting, and learning how to effectively chain prompts.</p>
<p>In a nutshell, it lets you build AI-generated apps in a Playground powered by <a target="_blank" href="https://aws.amazon.com/de/bedrock/">Amazon Bedrock</a>. Just go to <a target="_blank" href="https://partyrock.aws/">https://partyrock.aws/</a> and create your own funny apps, based on prompt engineering, and share them with the world.</p>
<h3 id="heading-background">Background</h3>
<p>PartyRock provides you with a Playground, where you can drag and drop widgets like:</p>
<ul>
<li><p><strong>user input</strong></p>
</li>
<li><p><strong>static text</strong></p>
</li>
<li><p><strong>AI-powered: text generation, image and chatbot</strong> 🚀</p>
</li>
</ul>
<p>You can think of the Playground as a list of functions (Widgets) backed up by Prompts. Every function produces results via prompt engineering, and these results can be concatenated throughout the entire setup via a dynamic variables chain.</p>
<p>Here in the example, the value of the User-Input Widget is included in the Prompt of the second Widget below. See also how the output is populated via variables to the second prompt.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1700523819445/4f1d7553-21fe-4659-9e9a-060ab343f5f3.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-use-case"><strong>Use Case</strong></h3>
<p>Let's say you want to build an app that analyzes your business requirements and conducts automatic EventStorming sessions. Based on the results, it generates the domain objects and a fully working serverless architecture with CDK code. 🙂</p>
<p>Just hit the <a target="_blank" href="https://partyrock.aws/">landing page</a> and describe your idea:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1700524090773/cbd46136-0bf7-4f33-b81a-2151fffbaac3.png" alt class="image--center mx-auto" /></p>
<p><strong>Here we go, you can find the app here:</strong></p>
<p><a target="_blank" href="https://partyrock.aws/u/odemis/TqzflOT9e/EventStormServerless">https://partyrock.aws/u/odemis/TqzflOT9e/EventStormServerless</a></p>
<h3 id="heading-play-with-it">Play with it</h3>
<p>Enter your business requirement in <strong>User Input-Widget</strong> e.g:</p>
<p><em>"A logistics company wants to improve its fleet management through a smart system that optimizes routes, tracks vehicle status, and manages deliveries. The system aims to enhance operational efficiency, reduce fuel consumption, and ensure timely deliveries."</em></p>
<p><strong>The Output:</strong></p>
<ul>
<li><p>Generates your domain events.</p>
</li>
<li><p>Produces the CDK Code, including components like Lambda, EventBridge, DynamoDB, etc.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1700524339619/9efc6e28-53f7-492f-851d-017844a3313a.png" alt class="image--center mx-auto" /></p>
<p>The CDK code comments out certain parts, but you can go deeper into specific implementation details in the next step via the <strong>Technology Wizard.</strong> For instance, if you wish to view details about the implementation of the generated lambdas, simply enter the name, and the output will be displayed in the next <strong>Component Widget</strong>. 👇🏽</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1700524566447/4b60499c-fb4c-4d80-9583-239b72083960.png" alt class="image--center mx-auto" /></p>
<p>You can also add new widgets, edit an existing widget, and play with the prompt, mode, and temperature settings.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1700526155592/e84acc19-a034-45de-b670-0755274a39d0.png" alt class="image--center mx-auto" /></p>
<p>Happy coding 🥳</p>
]]></content:encoded></item><item><title><![CDATA[Serverless event-driven architectures]]></title><description><![CDATA[Hello, folks how are you?
Here again with a new topic - event-driven architectures 🚀
If you enter the world of microservice-style architectures in the cloud you are confronted sometimes with the terms like:

serverless architectures

resilient archi...]]></description><link>https://blog.oedemis.io/serverless-event-driven-architectures</link><guid isPermaLink="true">https://blog.oedemis.io/serverless-event-driven-architectures</guid><category><![CDATA[event-driven-architecture]]></category><category><![CDATA[serverless]]></category><category><![CDATA[AWS]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[Osman Recai Ödemis]]></dc:creator><pubDate>Tue, 06 Dec 2022 14:01:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1670335162130/UnzlNa3lz.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello, folks how are you?</p>
<p>Here again with a new topic - event-driven architectures 🚀</p>
<p>If you enter the world of microservice-style architectures in the cloud you are confronted sometimes with the terms like:</p>
<ul>
<li><p>serverless architectures</p>
</li>
<li><p>resilient architectures</p>
</li>
<li><p>reactive programming</p>
</li>
<li><p>independent deployments</p>
</li>
<li><p>message-driven architectures</p>
</li>
<li><p>...</p>
</li>
</ul>
<p>the list can be growing. But from my perspective at the heart is the concept of event-driven systems. What it means event-driven and where do we start? First I give you the counterpart of this style of architecture the synchronous microservices and introduce you further into the world of asynchronous events.</p>
<h3 id="heading-synchronous-microservices">Synchronous microservices?</h3>
<p>If you start developing apps most of the time we architect our system around the concept of synchronous invocations.</p>
<p>Suppose you have an upstream service <strong>"Shopping Cart"</strong> and three downstream services <strong>"Billing"</strong>, <strong>"Warehouse"</strong> and "<strong>E-Mail"</strong>. In a synchronous style of development, the upstream-service calls directly the downstream-services and waits until the result is received.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670278890390/j5BFDO4iU.png" alt="image.png" /></p>
<p><strong>But wait what's the problem with this style?</strong> The problem is in tight coupling which can produce crazy spaghetti code 🤯.</p>
<p>some further drawbacks:</p>
<ul>
<li><p><strong>receiver failure</strong>, what if Billing Service breaks?</p>
</li>
<li><p><strong>throttling</strong> of downstream services, what if <strong>Analytics Service</strong> doesn't respond timely</p>
</li>
<li><p><strong>scalability</strong> issues, the ability to scale up your one service depends on the ability of all dependent services to scale up</p>
</li>
<li><p><strong>API versioning</strong> and maintenance of multiple versions can be very complex due to dependent services =&gt; we need some orchestration</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670280517752/-Y1Nh5btq.png" alt="image.png" /></p>
<h2 id="heading-our-solution-event-driven-architecture">Our Solution: Event-driven architecture</h2>
<p>Let's first understand the word <strong>"Event"</strong> here:</p>
<p><strong><em>"An Event is something that happened in the domain that you care about."</em></strong></p>
<p>An event in the domain of e-commerce can be <strong>an OrderPlaced</strong> Event.</p>
<p>It has some important characteristics:</p>
<ul>
<li><p>it tells a fact</p>
</li>
<li><p>it's immutable</p>
</li>
<li><p>observable</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670282584186/stObTJYZo.png" alt="image.png" /></p>
<p><a target="_blank" href="https://www.eventstorming.com/">Event storming</a> is a powerful concept where you model your business processes around events and identify microservices.</p>
<h3 id="heading-but-what-do-we-do-with-these-events-in-order-to-build-architecture"><strong>But what do we do with these events in order to build architecture?</strong></h3>
<p><strong>We asynchronously communicate the events as messages between our microservices.</strong> In asynchronous communication, the service which produces the event publishes it in our infrastructure, and other interested services can consume these events.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670282327458/T44Nii6Cf.png" alt="image.png" /></p>
<p>This brings some advantages compared to synchronous style:</p>
<ul>
<li><p><strong>loosely decoupling</strong> =&gt; eliminate the impact of changes for services</p>
</li>
<li><p>independent <strong>scalability</strong></p>
</li>
<li><p><strong>cross-functional</strong> teams =&gt; without dependency on other teams which are responsible for the service</p>
</li>
<li><p>independent <strong>deployments</strong></p>
</li>
<li><p>... many more</p>
</li>
</ul>
<p>But enough theory, we enter some practical AWS services.</p>
<h2 id="heading-what-offers-aws">What offers AWS?</h2>
<p>AWS offers you many solutions for building event-driven architectures. <a target="_blank" href="https://aws.amazon.com/eventbridge/?nc1=h_ls">EventBridge</a> is one of the popular services, where we start our event-driven journey.</p>
<p>According to AWS: <strong><em>"Amazon EventBridge is a serverless event bus that helps you receive, filter, transform, route, and deliver events."</em></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670284369750/jdvle7W3v.png" alt="image.png" /></p>
<h3 id="heading-what-is-this-bus-in-eventbridge">What is this Bus in EventBridge? 🚌🚌</h3>
<p>They mention here the concept of <strong>bus</strong>. Simply EventBridge stores all the events on the bus. Your account has one default event bus, which receives all the events from AWS services in your account. Yeah, that's very cool, AWS is built around an event-driven architecture 🚀 When you start your event-driven architecture journey first you create your custom event buses to receive events from your custom applications.</p>
<p>Ok, let's hack into the AWS console, go to the console and enter <strong>EventBridge.</strong></p>
<ul>
<li><p>You will create a custom <a target="_blank" href="https://aws.amazon.com/eventbridge/">EventBridge</a></p>
</li>
<li><p>You will create a new rule in <a target="_blank" href="https://aws.amazon.com/eventbridge/">Amazon EventBridge</a>.</p>
</li>
<li><p>You will see a sample event in JSON</p>
</li>
<li><p>You will configure this new rule to send it to a Lambda function target</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670296618529/R9K0eZPja.png" alt="image.png" /></p>
<h3 id="heading-events-in-eventbridge">Events in EventBridge?</h3>
<p>Ok, EventBridge is an amazing serverless bus where your events in JSON format are stored.<br />Here bellow is a sample event in JSON format that's EventBridge conform. The <strong>red box</strong> is the envelope and contains information about which service published the event, the type of event, account, timestamp, region, etc. The <strong>blue box</strong> contains the actual event payload.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670293502050/nTXjeDBJv.png" alt="image.png" /></p>
<h3 id="heading-how-do-we-deliver-events">How do we deliver events? 🔔</h3>
<p>Our interested services are notified via <strong>rules</strong> which must be set up in EventBridge. A rule matches incoming events and routes them to targets for processing. A single rule can route to multiple targets, all of which are processed in parallel.</p>
<p>For example, here we catch all events from the service <strong>com.aws.orders</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670293662033/975Vqob-0.png" alt="image.png" /></p>
<h3 id="heading-how-do-targets-get-called">How do targets get called? 🎯🎯</h3>
<p>After evaluating the rule the registered targets are called automatically. The targets must be set up after we create the rule. The target service can be a for example Lambda function that writes the order to DynamoDB.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670295667203/R5TNt-cOr.png" alt="image.png" /></p>
<p>In the end, we have the following architecture:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670333663530/sZ_3-_om1.png" alt="blog.arch.png" /></p>
<h3 id="heading-real-world-example">Real-World example:</h3>
<p>What I love about AWS and the community is the amazing <a target="_blank" href="https://aws.amazon.com/blogs/aws/">blog</a> and of course, the labs provided by the workshops. If you are also a pragmatic programmer, I suggest you try this <a target="_blank" href="https://workshop.serverlesscoffee.com/">amazing workshop</a>. In the end, you end up with a fully working event-driven architecture below. Many AWS services react during events flow in the system like StateMachines, API Gateways, etc.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670334474497/58jTG4-OF.png" alt="image.png" /></p>
<h1 id="heading-conclusion"><strong>Conclusion</strong></h1>
<p>In this first post, I want to give you a high-level overview. In further posts, I plan to go deeper into the landscape of asynchronous event-driven style.</p>
<p>I highly recommend watching the session from Amazon CTO Werner Vogels at re:Invent 2022. He talks about why event-driven architectures enable global scale and why the world is asynchronous in nature 😀 Further he also referred to the <a target="_blank" href="https://www.allthingsdistributed.com/2022/11/amazon-1998-distributed-computing-manifesto.html">Distributed Computing Manifesto</a>, a document from the early days of Amazon.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/RfvL_423a-I">https://youtu.be/RfvL_423a-I</a></div>
]]></content:encoded></item><item><title><![CDATA[Don't use GWT or Google Web Toolkit?]]></title><description><![CDATA[Hello folks how are you?
Today I want to write about maybe the forgotten web framework from Google - Google Web Toolkit or GWT. Attention by forgotten I mean, we don't see news about GWT every day on hackernews but it is used under oldschool Java dev...]]></description><link>https://blog.oedemis.io/dont-use-gwt-or-google-web-toolkit</link><guid isPermaLink="true">https://blog.oedemis.io/dont-use-gwt-or-google-web-toolkit</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Java]]></category><category><![CDATA[Google]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[npm]]></category><dc:creator><![CDATA[Osman Recai Ödemis]]></dc:creator><pubDate>Tue, 02 Nov 2021 17:38:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1700562399615/4720ea69-ed26-4ecd-bb32-009029bc80a3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello folks how are you?</p>
<p>Today I want to write about maybe the forgotten web framework from Google - Google Web Toolkit or GWT. Attention by forgotten I mean, we don't see news about GWT every day on <a target="_blank" href="https://news.ycombinator.com/">hackernews</a> but it is used under oldschool Java devs and enterprises 😃</p>
<h1 id="heading-history-of-gwt"><strong>History of GWT</strong></h1>
<p><a target="_blank" href="http://www.gwtproject.org/">GWT</a> is developed by Google in 2006 when Single Page Applications (SPA) or AJAX-intensive apps become very popular. Google Docs, Google Mails ... all these web-apps are SPAs and must behave like desktop apps in browsers.</p>
<p>Back then it was very challenging to develop maintainable JavaScript software architectures with frameworks like <a target="_blank" href="https://jquery.com/">JQuery</a>. On the other side programming languages like Java or C# have a very proven history in backend development for creating maintainable code. We have <a target="_blank" href="https://en.wikipedia.org/wiki/Software_design_pattern">design patterns</a> to produce effective architectures. The solution from Google in 2006: <strong>creating frontend architectures with Java</strong> 🚀</p>
<h1 id="heading-idea-of-gwt"><strong>Idea of GWT</strong></h1>
<p>We develop our web apps in Java ⛏️. If you are already Java dev switching to frontend back was very easy. Google Web Toolkit has a built-in compiler, which compiles your Java code in JavaScript.</p>
<p>The basic idea is like NodeJs web frameworks like <a target="_blank" href="https://expressjs.com/">Express</a>, we develop our backend and frontend parts in Java - We are Fullstack developers 🚀</p>
<p>For example, this code produces a button in the browser and if you click you receive a nice alert message:</p>
<pre><code class="lang-plaintext">@Override
    public void onModuleLoad() {
        Button button = new Button("Click me");
        button.addClickHandler(clickEvent -&gt; {
            Window.alert("Hello World from Java!");
        });

        RootPanel.get("helloButton").add(button);
    }
</code></pre>
<h1 id="heading-ui-libs"><strong>UI Libs</strong></h1>
<p>In modern web dev, we can pick up some UI components from <a target="_blank" href="https://getbootstrap.com/">Bootstrap</a> or <a target="_blank" href="https://bulma.io/">Bulma</a>. There are tons of UI libs for public use.</p>
<p>In GWT we have the standard <a target="_blank" href="http://www.gwtproject.org/doc/latest/RefWidgetGallery.html">gwt-widget</a> library from Google and very old dated framework like <a target="_blank" href="https://examples.sencha.com/gxt/examples/">GXT</a>. The disadvantage of this approach is, Its very hard to make it a modern look with CSS and not implement the modern HTML5 approach. Another modern approach is <a target="_blank" href="https://demo.dominokit.org/home">DominoKit</a>, I highly recommend it If you want to go with GWT.</p>
<h1 id="heading-how-to-start-with-gwt">How to start with GWT</h1>
<p>If you visit the <a target="_blank" href="http://www.gwtproject.org/">website</a> of GWT, maybe you see in the getting started sections commands like 😟:</p>
<pre><code class="lang-plaintext">ant devmode
</code></pre>
<p>Come on ... I personally don't use ant build, we have in modern Java ecosystem build tools like <strong>gradle</strong> or <strong>maven</strong>. Instead, use this site only for <a target="_blank" href="http://www.gwtproject.org/doc/latest/DevGuide.html">documentation</a>.</p>
<p>If you want to start very quickly with GWT, please go to this <a target="_blank" href="https://github.com/gwtboot/gwt-boot-samples">repo</a> with samples and starters. You need maven and start your IDE 🚀.</p>
<p>Please give this project on Github star, it's actually very awesome to start quickly with GWT.</p>
<h1 id="heading-2021-2022">2021, 2022, ... ?</h1>
<p>In June 2012, Google handed control to the <a target="_blank" href="http://www.gwtproject.org/steering.html">steering committee</a>, to make GWT more visible in the open source community.</p>
<p>Ok but we are already in 2021 and you can read on news or social media <strong>GWT is dead</strong>. They are right, GWT 2 is dead. But it means <strong>not</strong> that the framework is not more developed, it is heavily developed. The new approach uses a different compiler named <a target="_blank" href="https://github.com/google/j2cl">J2CL</a> by Google and the community makes GWT APIs J2CL compatible with version GWT 3.0.</p>
<p>The difference between J2Cl and the old compiler from GWT 2.* is that J2Cl is only a transpiler, which transpiles your Java code in Closure style JavaScript.</p>
<p>From a programming perspective it changes nothing, the APIs are ported further and you can develop further your web apps in Java. But the toolchain is slimmer.</p>
<h2 id="heading-why-java-in-frontend">Why Java in Frontend ?</h2>
<h2 id="heading-we-have-frameworks-like-vue-react-or-svelte">We have frameworks like Vue, React or Svelte... 🚀🚀🚀</h2>
<p>From my perspective developing web apps in Java must be evaluated before the project starts. The following points are very important to choose GWT.</p>
<ul>
<li><p>you are already an experienced Java dev</p>
</li>
<li><p>you don't plan to use complex JavaScript frameworks dependency for your app</p>
</li>
<li><p>BUT some Js Frameworks are ported to GWT 😃 google it like <a target="_blank" href="https://vuegwt.github.io/vue-gwt/">VueGWT</a> but not the full specification of Vue</p>
</li>
<li><p>you have a minimal CRUD app with simple UI components</p>
</li>
</ul>
<p>If you break the requirements the code can be very challenging over time, there is also a <a target="_blank" href="https://docs.google.com/presentation/d/1Dgairc6uDtTEZI92Z6mca4k8f1GgbzY8l59FhDW-nik/htmlpresent">JsInterop Specification</a> from Google where you can bind any JS-Framework like VueJs in GWT, but it becomes very challenging in maintainability over a long time.</p>
<p><strong>And why you must port it to Java ???? If you have an awesome Js-Framework 😃</strong></p>
<p>But if you are an experienced oldschool Java dev and need a small web app with not too many fancy UI <strong>requirements</strong> go with GWT.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>We read news about <a target="_blank" href="https://webassembly.org/">WASM</a> and polyglot architectures for web apps in languages other than JavaScript like <a target="_blank" href="https://elm-lang.org/">Elm</a>. Maybe in some years also GWT becomes again popular under the top news.</p>
<p>But the lack of documentation, examples and small community makes it very difficult to switch to GWT. There are two awesome Gitter channels vertispan and <a target="_blank" href="https://gitter.im/gwtproject/gwt">gwt</a> where GWT experts talk every day about problems and ideas please look if you are interested.</p>
<p>Please give me feedback if you use GWT in your projects</p>
<p>Happy coding 😃</p>
]]></content:encoded></item><item><title><![CDATA[Intro to Infrastructure as Code (IaC) in AWS context]]></title><description><![CDATA[Hello devs
This post is about the following AWS picture:

Ok ... We have here in the cloud parts of the picture the following AWS cloud components:

Cloudformation - Infrastructure as Code service from AWS to deploy aws components

S3 - object storag...]]></description><link>https://blog.oedemis.io/intro-to-infrastructure-as-code-iac-in-aws-context</link><guid isPermaLink="true">https://blog.oedemis.io/intro-to-infrastructure-as-code-iac-in-aws-context</guid><category><![CDATA[AWS]]></category><category><![CDATA[Cloud Computing]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Java]]></category><dc:creator><![CDATA[Osman Recai Ödemis]]></dc:creator><pubDate>Fri, 24 Sep 2021 21:26:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1632518683607/mLIiqzrZq.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello devs</p>
<p>This post is about the following AWS picture:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670792957085/WQ2uz_iBb.png" alt class="image--center mx-auto" /></p>
<p>Ok ... We have here in the cloud parts of the picture the following AWS cloud components:</p>
<ul>
<li><p><a target="_blank" href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html">Cloudformation</a> - Infrastructure as Code service from AWS to deploy aws components</p>
</li>
<li><p><a target="_blank" href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html">S3</a> - object storage service, you can deploy here big data</p>
</li>
<li><p><a target="_blank" href="https://aws.amazon.com/cloudfront/">Cloudfront</a> - CDN service from AWS</p>
</li>
<li><p><a target="_blank" href="https://aws.amazon.com/lambda/">Lambda</a> - Serverless on AWS 🚀</p>
</li>
<li><p>....</p>
</li>
</ul>
<p><strong>The list can be around 200 services 😀</strong></p>
<p>To deploy these AWS services you have many options. If you quickly test around you can use the AWS console. But if you want more reproducible architecture with CI/CD chain or deployments over stages with many accounts, in Cloud-Native development there are solutions named under the buzzword <strong>IaC (Infrastructure as Code)</strong>.</p>
<p>IaC code creates your infrastructure which is composed of cloud services, like S3. <strong>The advantage is we can handle your infrastructure like source code</strong> 😀</p>
<h1 id="heading-entering-cloudformation">Entering Cloudformation</h1>
<p>Cloudformation is IaC service from AWS which accepts <em>YML</em> or <em>JSON</em> formatted files and deploys the described infrastructure from these files. Yes, Cloudformation is a setup as <em>YML</em> or <em>JSON</em> file 😀</p>
<p>For example, the following snippet describes an S3-Bucket (<em>YML</em>-formatted):</p>
<pre><code class="lang-plaintext"> MyS3Bucket:
    Type: 'AWS::S3::Bucket'
    Properties:
      BucketName: !Join
        - '-'
        - - !Ref S3BucketName
          - !Ref 'AWS::Region'
</code></pre>
<p>The problem with Cloudformation is, these YML or JSON files can be very complex for big cloud architectures. Refactoring can be a disaster, therefore over the years many IaC frameworks are developed, so we enter <strong>IaC Frameworks</strong> or <strong>abstractions over Cloudformation</strong></p>
<ul>
<li><p><a target="_blank" href="https://www.terraform.io/">Terraform</a></p>
</li>
<li><p><a target="_blank" href="https://www.pulumi.com">Pulumi</a></p>
</li>
<li><p><a target="_blank" href="https://docs.aws.amazon.com/cdk/latest/guide/home.html">CDK (from AWS)</a></p>
</li>
<li><p><a target="_blank" href="https://www.serverless.com/">Serverless Framework</a></p>
</li>
<li><p><a target="_blank" href="https://docs.serverless-stack.com/installation"><strong>SST</strong></a></p>
</li>
</ul>
<p>There are much more frameworks, every one with his strength and different paradigm.</p>
<p>All these frameworks produces in AWS as cloud provider, Cloudformation code except Terraform and Pulimi, which creates and deploys your services. Framworks like CDK, Serverless Framework or SST is only <strong>abstraction</strong> over Cloudformation, to make it easier to develop your infrastructure.</p>
<p>For example following SST-Snippet creates an S3-Bucket named Uploads.</p>
<pre><code class="lang-plaintext">let bucket = new sst.Bucket(this, "Uploads");
</code></pre>
<p>You see the difference, SST framework in this case uses another abstraction layer over CDK and has a programming paradigm for creating IaC 😀</p>
<p>Happy Coding 😀</p>
]]></content:encoded></item><item><title><![CDATA[Çirali: Travel tip in soutwest Türkiye]]></title><description><![CDATA[Hello folks 
Traveling around is one of my philosophy ...
I want suggest you a place on the Lycian Way in southwest of Turkey where you can stay very peacefully.
The little village Çirali near Kemer in Antalya.
Smell of flowers, birds flying and the ...]]></description><link>https://blog.oedemis.io/cirali-travel-tip-in-soutwest-turkiye</link><guid isPermaLink="true">https://blog.oedemis.io/cirali-travel-tip-in-soutwest-turkiye</guid><category><![CDATA[Travel]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[remote]]></category><category><![CDATA[training]]></category><dc:creator><![CDATA[Osman Recai Ödemis]]></dc:creator><pubDate>Sat, 18 Sep 2021 13:12:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1631971116621/1uoQUMYc7.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello folks </p>
<p>Traveling around is one of my philosophy ...</p>
<p>I want suggest you a place on the Lycian Way in southwest of Turkey where you can stay very peacefully.
The little village Çirali near Kemer in Antalya.
Smell of flowers, birds flying and the mediterranean sea gives the village his very good vibes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631969615834/mMbDs540D.jpeg" alt="lycway2.JPG" /></p>
<p>The village is also very interesting for digital nomads, you can stay in bungalows with garden and seafront view 😀 internet connections is well suited for devs </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631968815234/QgEtgjUxo.jpeg" alt="bungalowstyle.JPG" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631970493123/h7-fhyVEd.jpeg" alt="bung1.jpg" /></p>
<p>The village has a beatiful long beach, which is part of a protected area as it’s used by sea turtles to lay their eggs.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631969121438/F6UPlMOQNX.jpeg" alt="beachcirali1.JPG" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631969172138/owZ9jzv5G.jpeg" alt="ciralibeach2.JPG" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631970532009/GJHxJ3_Of.jpeg" alt="legs.jpg" /></p>
<p>You can walk to the ancient ruins of Olympos and Chimaera, which is part of the Lycian Way.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631969817714/ar_0xGqdC.jpeg" alt="olympos1.JPG" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631969891008/_CsVeEDJI.jpeg" alt="olympos3.JPG" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631969865872/yIp050D-O.jpeg" alt="olympos3.jpg" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1631969930689/_aFSbEow1.jpeg" alt="Chimaera1.JPG" /></p>
<p>Happy Coding 😀</p>
]]></content:encoded></item><item><title><![CDATA[Start with AWS Container Technologies]]></title><description><![CDATA[Hi devs around the world
I plan to write a series of blog posts about AWS container technologies. In this first article i blog about a quick intro and a high level overview of the services. In later posts I go deep dive in the services and show you s...]]></description><link>https://blog.oedemis.io/start-with-aws-container-technologies</link><guid isPermaLink="true">https://blog.oedemis.io/start-with-aws-container-technologies</guid><category><![CDATA[AWS]]></category><category><![CDATA[Docker]]></category><category><![CDATA[containers]]></category><category><![CDATA[ECS]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[Osman Recai Ödemis]]></dc:creator><pubDate>Sun, 17 Jan 2021 19:18:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610917563821/pyRgyESL3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hi devs around the world</p>
<p>I plan to write a series of blog posts about AWS container technologies. In this first article i blog about a quick intro and a high level overview of the services. In later posts I go deep dive in the services and show you some examples.</p>
<p>Happy Reading 😃</p>
<h1 id="heading-first-quick-history"><strong>First Quick History</strong></h1>
<p>First the journey begins with <a target="_blank" href="https://aws.amazon.com/ec2/"><strong>Amazon Elastic Compute Cloud</strong></a> or <strong>EC2</strong>. EC2 are virtual machines where you can host your apps on AWS. You can think there is a machine hosted on Amazon's data centers across the globe and you can rent an environment where you can deploy your app.</p>
<p>The image below illustrates this scenario with <strong>4 applications</strong> in one EC2-Machine.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1610903424083/UjIIDMDLs.png" alt="ec2.png" /></p>
<p>This architecture implies that you must configure and install all your required packages and configurations for each app <strong>directly on the EC2 Instance</strong>. But there are many long automation processes involved:</p>
<ul>
<li><p>update your tomcat configuration</p>
</li>
<li><p>need another system-wide package</p>
</li>
<li><p>scale to 1000 EC2 Instances 😮</p>
</li>
<li><p>...</p>
</li>
</ul>
<p>The list goes on, you must every time log in to your EC2 and update or patch these requirements and this is not a good development experience</p>
<p>But there is a solution for automation - DOCKER or containerized applications 😝</p>
<p><strong>Automated Solution Docker</strong></p>
<p>With the rise of Container tech especially <a target="_blank" href="https://www.docker.com/">Docker</a>, the deployment and development of applications are more repeatable and automated. We can define our environments, packages and so on for each application in a central <strong>Dockerfile</strong> on our local machine and the deployment of our application environment is automated on each hosted machine on every deployment.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1610905416242/e-Sa4JQhg.png" alt="docker.png" /></p>
<h1 id="heading-entering-container-services-for-aws"><strong>Entering Container Services for AWS</strong></h1>
<p>AWS offers two basic services for deploying containerized Applications on AWS</p>
<ul>
<li><p><a target="_blank" href="https://aws.amazon.com/fargate/">Amazon Elastic Container Service</a></p>
</li>
<li><p><a target="_blank" href="https://aws.amazon.com/ecs/">Amazon Fargate</a></p>
</li>
</ul>
<p>With ECS we have the concept of container technology. AWS defines the following building blocks in ECS</p>
<ul>
<li><p><strong>Cluster</strong></p>
</li>
<li><p><strong>Task definitions</strong></p>
</li>
<li><p><strong>Tasks</strong></p>
</li>
<li><p><strong>Services</strong></p>
</li>
</ul>
<p>Don't worry we go deeper in further posts to the building blocks mentioned. It's important first to understand at a high level what's going on and the philosophy behind them.</p>
<h1 id="heading-introduce-ecs"><strong>Introduce ECS</strong></h1>
<p>Bellow diagram illustrates the concepts at high-level architecture. We have further an <strong>EC2-Instance</strong> but this time we have an <strong>ECS-Agent</strong> installed on that EC2, which is responsible to manage the Docker-Container and register this as an AWS service. The execution of a Docker container in EC2-Instance is called a <strong>Task</strong>.</p>
<p>Summarize:</p>
<ul>
<li><p>Containerize the app (create Dockerfile)</p>
</li>
<li><p>EC2-Instance with running ECS-Agent</p>
</li>
<li><p>ECS-Agent manages dockerized apps as Tasks and registers it as AWS service</p>
</li>
<li><p>Run dockerized App in EC2 as <strong>Task</strong></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1610908409949/XDDJgI4lg.png" alt="first.ecs.png" /></p>
<p>** ECS-Agent **</p>
<p>The ECS-Agent registers our machine in a <strong>Cluster</strong>. This <a target="_blank" href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html">Cluster</a> orchestrates our Tasks and Services.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1610909593522/6efziVs7Q.png" alt="cluster.png" /></p>
<p>** What if we need to scale up ?**</p>
<p>In order to handle the increased load we need to run more EC2-Instances with ECS-Agent installed.</p>
<p>AWS helps us to create EC2-Instances automatically with <a target="_blank" href="https://aws.amazon.com/autoscaling">Auto-Scaling Service</a>, but I go deeper with this building block in another post.</p>
<p>For this post, we create another EC2-Instance manually with ECS-Agent installed and deploy our dockerized apps on it. The Agent registers the EC2-Instance automatically at the Cluster Level.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1610909737387/a0ebZjcdc.png" alt="cluster_scale.png" /></p>
<p>First that all about ECS at a high level, I go deeper in further posts 😊</p>
<h1 id="heading-introduce-fargate"><strong>Introduce Fargate</strong></h1>
<p>Image your next application becomes very popular and your EC2-Instances hit heavy load from your users. You have no time to go down and won't scale up to 1000 EC2-Instances, this scenario is very cumbersome and buggy.</p>
<p>** From AWS Docs **</p>
<blockquote>
<p>AWS Fargate is a serverless compute engine for containers that work with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). Fargate makes it easy for you to focus on building your applications. Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application, and improves security through application isolation by design.</p>
</blockquote>
<p>Ok ok, AWS mentions the buzzword <a target="_blank" href="https://en.wikipedia.org/wiki/Serverless_computing">Serverless</a> 😂</p>
<p>Yesss this is amazing, Serverless is also explained in the above Quote from Amazon:</p>
<blockquote>
<p>Fargate makes it easy for you to focus on building your applications. Fargate removes the need to provision and manage servers,</p>
</blockquote>
<p>This is very amazing you don't need to create and manage EC2-Instances, create your dockerized applications, push them to Amazon and run it as <strong>Fargate Tasks</strong>. If you want to scale up you only increase the number of your running Tasks.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1610910615871/kyAbTWpOQ.png" alt="fargate_serverless.png" /></p>
<p>As you can see from the diagram above we have the building blocks from ECS, except Agent and EC2.</p>
<p>I prefer Fargate as AWS Service for building containerized applications on AWS, because I can focus on my business logic rather than infrastructure.</p>
<p>This article was only a high-level of introduction to AWS Container Ecosystem. In further posts, I go deeper with Fargate and the concepts behind the building blocks.</p>
<p>Happy coding and reading 🚀 ! Stay healthy</p>
]]></content:encoded></item></channel></rss>