<?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 Berna Simsek on Medium]]></title>
        <description><![CDATA[Stories by Berna Simsek on Medium]]></description>
        <link>https://medium.com/@simskberna?source=rss-979c9d1fe7e4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8EA5cf0S9vGegyQJrA0TrQ.jpeg</url>
            <title>Stories by Berna Simsek on Medium</title>
            <link>https://medium.com/@simskberna?source=rss-979c9d1fe7e4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:20:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@simskberna/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[Performance Testing for Real-Time Apps with TypeScript and Node.js]]></title>
            <link>https://medium.com/@simskberna/performance-testing-for-real-time-apps-with-typescript-and-node-js-15f348ae66d5?source=rss-979c9d1fe7e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/15f348ae66d5</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[realtimeapps]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[performance-testing]]></category>
            <dc:creator><![CDATA[Berna Simsek]]></dc:creator>
            <pubDate>Fri, 04 Apr 2025 16:39:44 GMT</pubDate>
            <atom:updated>2025-04-04T17:44:17.910Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*3ywF-Rlenx4HrfVHEXG9XQ.png" /></figure><p>If you’ve developed a real-time app (be it a chat platform, live scoreboard, or financial dashboard ) there’s a thrill in watching data stream instantly. But amidst all the excitement, there’s one major challenge: <strong>performance testing</strong>.</p><p>As a developer working with TypeScript and Node.js, I’ve learned the hard way that performance testing can make or break your app. Clean code is important, but if your app crashes when traffic spikes, it won’t matter. You need to understand how your system performs when thousands of users are interacting at once.</p><h4>Why Performance Testing is Crucial for Real-Time Apps</h4><p>Real-time apps aren’t like traditional web apps. They involve continuous data streams, multiple concurrent connections, and strict latency requirements. Imagine if your app lagged during a live chat or financial transaction. It is a disaster waiting to happen.</p><p>Key reasons performance testing is essential:</p><ol><li>From chat apps to stock trading platforms, your server needs to handle hundreds or even thousands of concurrent users.</li><li>Real-time means instant. No one wants delays in sending messages or seeing live game updates.</li><li>Continuous Data Flow. Whether it’s messages, notifications, or live stock prices, your app needs to <strong>stream data</strong> without interruptions.</li></ol><p>The only way to ensure your app delivers a smooth experience is to test it under real-world load before going live.</p><h3>Selecting the Right Tools for Testing 🛠️</h3><p>Before diving into testing, you need to choose the right tools. These are my favorites:</p><p><strong><em>Artillery</em>: </strong>Lightweight yet powerful. Perfect for simulating WebSocket and HTTP traffic.</p><p><strong><em>JMeter</em>: </strong>More complex, but ideal for large-scale simulations.</p><p><strong><em>Loader.io</em>: </strong>A cloud-based tool that allows you to simulate thousands of users with minimal setup.</p><p>For real-time apps, testing WebSockets is a must. Here’s how I use Artillery for that purpose.</p><h3>Load Testing with WebSockets</h3><p>Most real-time apps use WebSockets to maintain low-latency, persistent connections. If you’re working with Socket.io or ws, you need to ensure your server can handle multiple WebSocket connections simultaneously.</p><p>Install Artillery globally:</p><pre>npm install -g artillery</pre><p>Create a test configuration file (test.yml):</p><pre>config:<br>  target: &#39;ws://localhost:3000&#39;<br>  phases:<br>    - duration: 60<br>      arrivalRate: 10<br>scenarios:<br>  - engine: &#39;ws&#39;<br>    flow:<br>      - send: &#39;{&quot;event&quot;: &quot;ping&quot;}&#39;<br>      - think: 5<br>      - send: &#39;{&quot;event&quot;: &quot;pong&quot;}&#39;</pre><p>This configuration simulates 10 new WebSocket connections per second over 60 seconds, where each connection sends a ping and waits for the pong response.</p><p>Run the test with:</p><pre>artillery run test.yml</pre><p>Once completed, Artillery will provide insights into response times, success rates, and potential bottlenecks.</p><h3>Load Testing Your Node.js Server</h3><p>If your real-time app supports hundreds or thousands of users simultaneously, your Node.js server must handle the load efficiently. One way to achieve this is by implementing Node.js clustering to fully leverage multi-core CPUs.</p><p>Here’s an example of a clustered server setup:</p><pre>import cluster from &#39;cluster&#39;;<br>import http from &#39;http&#39;;<br>import os from &#39;os&#39;;<br><br>const numCPUs = os.cpus().length;<br><br>if (cluster.isMaster) {<br>  for (let i = 0; i &lt; numCPUs; i++) {<br>    cluster.fork();<br>  }<br><br>  cluster.on(&#39;exit&#39;, (worker) =&gt; {<br>    console.log(`Worker ${worker.process.pid} died`);<br>  });<br>} else {<br>  http.createServer((req, res) =&gt; {<br>    res.writeHead(200);<br>    res.end(&#39;Hello World\n&#39;);<br>  }).listen(8000);<br>}</pre><p>In this setup, the server spins up one worker per CPU core, helping distribute requests more efficiently.</p><p>To test the server’s performance, create another test configuration file (test.yml):</p><pre>config:<br>  target: &#39;http://localhost:8000&#39;<br>  phases:<br>    - duration: 10<br>      arrivalRate: 100<br>scenarios:<br>  - flow:<br>      - get: &#39;/&#39;</pre><p>Running this simulates 100 requests per second over 10 seconds, helping you determine if the server can handle the load.</p><h3>Analyzing the Results📊</h3><p>Once the tests are complete, it’s time to analyze the data and optimize.</p><p>Here are some common issues you may encounter:</p><ul><li>High CPU Usage: If your CPU usage is maxed out, it’s time to optimize your code or scale your infrastructure.</li><li>Memory Leaks: Long-running tests often reveal hidden memory leaks that can affect performance.</li><li>Network Bottlenecks: Too many WebSocket connections might overload your network.</li></ul><p>Some strategies to fix these issues:</p><ul><li>Optimize Asynchronous Code: Node.js excels at asynchronous operations, so avoid blocking calls and keep tasks non-blocking.</li><li>Leverage Redis for Caching: Using Redis to cache frequent queries reduces the load on your database.</li><li>Scale with Nginx: A reverse proxy like Nginx can help balance traffic across multiple servers.</li></ul><p>Performance testing is far from a box to check off,it’s vital for ensuring that your real-time app can handle heavy traffic, stay responsive and scale effectively.</p><p>By leveraging tools like Artillery, JMeter, and Loader.io, and implementing clustering and caching strategies, you can make sure your Node.js app is ready for any challenge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15f348ae66d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Observer Design Pattern]]></title>
            <link>https://medium.com/segmentify-tech/the-observer-design-pattern-2ad28f7b19a7?source=rss-979c9d1fe7e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ad28f7b19a7</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[observer-pattern]]></category>
            <category><![CDATA[observer-design-pattern]]></category>
            <category><![CDATA[women-who-code]]></category>
            <dc:creator><![CDATA[Berna Simsek]]></dc:creator>
            <pubDate>Thu, 27 Jan 2022 09:33:59 GMT</pubDate>
            <atom:updated>2022-01-27T10:18:21.495Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xfnb1PFMurCGzTDsfRriDA.png" /></figure><p>This article will discuss “The Observer Design Pattern” and why we use it.</p><p>First, let’s take a look at <strong>Design Patterns</strong>.</p><p>When we try to do some tasks, we need a workflow. By following the workflow, we make out some patterns. And sometimes, we use these same patterns for different tasks. Thus, we do not have to create another pattern, which gives us flexibility. In the same way, we can make a collective solution by creating a Design Pattern. Design Patterns offers a general repeatable solution to a commonly occurring problem.</p><p>We can examine Design Patterns under three different titles. These are:</p><p>1. Creational Patterns</p><p>2. Structural Patterns</p><p>3. Behavioural Patterns</p><p>Observer Design Pattern is a part of the Behavioural Patterns.</p><p>Behavioural Patterns provide interaction between objects, meaning they allow them to talk to each other. They serve dynamic behaviour using polymorphism.</p><p>Solving many problems to design object-oriented systems is possible with Behavioural Patterns. They use object composition instead of inheritance. So what are the differences between composition and inheritance?</p><p>When we talk about inheritance, child classes inherit from a parent class. The child classes can behave like the parent class. A hierarchy is formed, just like a relationship between the vehicle (parent class) and its types like a car and a bus(child classes).</p><p>The composition makes collaborative types by combining other types instead of inheriting a parent class. For example, imagine some music notes, and we make a composition by uniting them. We can see these music notes as the object types and the composition as the new emerging type.</p><p>The relationship between objects is the main difference in comparison of composition and inheritance.</p><p>The purpose of inheritance is to design a class on what it is. For example, let’s say we have a class Building and a class House. We can say the house is a type of building. On the other hand, the purpose of composition is to design a class on what it does. If we walk through the previous example, we have a class Building already and a class Bathroom; the house has a bathroom.</p><p>Let’s look at it from a different perspective: First, focus on inheritance.</p><figure><img alt="Class Bus and class Car inherit properties from class Vehicle." src="https://cdn-images-1.medium.com/max/480/0*g9xtydvycWpsZPll" /></figure><p>We have a parent class Vehicle, and we also have a Bus class and a Car class that will inherit some properties from the Vehicle class. Everything seems fine at this point. But if we want to include Elevator class, some things change. Because Elevator has not got a model, we can solve this by adding a Machine class. This means we expand the structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/0*6mA8ZXn1L45AiHYh" /></figure><p>Now it seems to be fixed. But if we need to add a Driver class, we should update the structure again like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ySAv2LaXVLIT9Dfe" /></figure><p>So when we need to add a new class, we will update the whole structure again, and admittedly this is a bit of a hassle.</p><p>Composition lightens this load. Let’s look at the same example again, but this time differently.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87a3a9c97a8decfd2d26ff2a6f09f4bc/href">https://medium.com/media/87a3a9c97a8decfd2d26ff2a6f09f4bc/href</a></iframe><p>So we have the same functionality. However, instead of updating and expanding the structure again, we define expressions and return their state and methods.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d331ac2f67c639307e0a470221130a40/href">https://medium.com/media/d331ac2f67c639307e0a470221130a40/href</a></iframe><p>And we can use it like below :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72be4bcae0d8046c2e23086e65af1bda/href">https://medium.com/media/72be4bcae0d8046c2e23086e65af1bda/href</a></iframe><p>It seems composition is a bit more flexible than inheritance, right?</p><p>Now it is easier to imagine how Behavioural Patterns behave. As there are different types of Design Patterns, there are also types of Behavioural Patterns. We can list them as Command Pattern, Interpreter Pattern, Iterator Pattern, Observer Pattern, etc.</p><p>Finally, it’s time to talk about the Observer Pattern.</p><p>Observer Pattern allows dependent objects to notify and update automatically when the state of an object has changed. You can think of it like event handlers. So when there is data that constantly changes, using Observer Pattern to let the other classes know about it is pretty helpful. This pattern is often referred to with subject and, of course, observer. Observer is an abstract class that should be notified when a state change occurs. Subject is a class that holds the registered observers which should be notified about changes.</p><p>Let’s go through the examples: Assume that there’s a weather station. We know that weather stations provide weather information. The information can include data such as temperature and humidity; it creates the weather data. This data is displayed somewhere so that anything relevant can get this information. Now let’s reconsider this scenario as subject/observer.</p><p>The weather data in this example is the ‘subject’ that we talk about. And the displayed data related to this weather data, such as forecast, statistics are the ‘observers’.</p><p>This structure works like this:</p><p>First, the observers will register or subscribe to the subject. Then, the new data will be sent to the observers on data change. And finally, the observers will be updated related to this change.</p><p>Let’s expand on another example and write some code. But, again, we will keep it simple.</p><p>Imagine a storyline where we have two divs and a button on a page, and by clicking the button, the action about the colour of the subscribed div will happen. The action is a colour change in this example.</p><p>We define a class named Observe that includes subs(), unsubs() and notify() methods. Subs() method will subscribe to the observer, unsubs() method will unsubscribe the observer and notify() method will be used for notifying the data changes. All the observers we have (data that changes depending on something) will be in the observers’ array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a89d33d41b78d95c1f29a13b150d1b5/href">https://medium.com/media/5a89d33d41b78d95c1f29a13b150d1b5/href</a></iframe><p>We define the elements we will use. After that, we create our observers. ‘updtDiv1’, ‘updtDiv2’.</p><p>We will go over div1, and everything we mentioned for that applies to div2 as well.</p><p>‘updtDiv1’ sets the colour of div1 as ‘red’. Now we create a constant from the Observe class named ‘newObs’. We call the subs() function for ‘updtDiv1’ and it subscribes. It means ‘updtDiv1’ will be in the observers’ array.</p><p>Clicking the change colour button notifies the changes (the divs’ colour change in this example (updtDiv1)). When we click the subscribe button for div1, it subscribes, and its colour changes. If we click unsubscribe, it unsubscribes and clicking the change colour button does not affect it anymore.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f04e33fa98454096c48d40cf4fc8984/href">https://medium.com/media/4f04e33fa98454096c48d40cf4fc8984/href</a></iframe><p>In addition, with a bit of HTML and CSS, we can also make this visually executable and display.</p><p>So here is The Observer Design Pattern, why we use it and how it works with plenty of examples. I hope you see now how useful it is, and you know what I mean when we talk about providing reusability.</p><p>In summary, the magic in Observer Design Pattern is that it can notify unlimited numbers of objects of a state change. This is because there are so many potential uses for it. So you can research and adapt more to your project, remember that there is no limit!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ad28f7b19a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/segmentify-tech/the-observer-design-pattern-2ad28f7b19a7">The Observer Design Pattern</a> was originally published in <a href="https://medium.com/segmentify-tech">Segmentify Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>