<?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 Rok Nemet on Medium]]></title>
        <description><![CDATA[Stories by Rok Nemet on Medium]]></description>
        <link>https://medium.com/@roknemet?source=rss-f02d23bf56d3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CzaEVgtew7HgAGtvFtc5JA.jpeg</url>
            <title>Stories by Rok Nemet on Medium</title>
            <link>https://medium.com/@roknemet?source=rss-f02d23bf56d3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:11:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@roknemet/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[Level 4 vs Level 7 Load Balancers]]></title>
            <link>https://medium.com/swlh/level-4-vs-level-7-load-balancers-4f9ebc2b393?source=rss-f02d23bf56d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f9ebc2b393</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[load-balancer]]></category>
            <dc:creator><![CDATA[Rok Nemet]]></dc:creator>
            <pubDate>Tue, 13 Dec 2022 20:10:26 GMT</pubDate>
            <atom:updated>2022-12-13T20:10:26.411Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OxqH450KRlZcP7zltBnDCQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@dnevozhai?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Denys Nevozhai</a> on <a href="https://unsplash.com/s/photos/network-of-highways?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Load balancing is a method of distributing network traffic across multiple servers to ensure maximum performance and reliability. It is a vital part of any large-scale network infrastructure, as it ensures that no single server is overwhelmed with requests and that the network remains available and responsive.</p><p>Load balancers come in different variants, each of which has its own specific set of features and capabilities.</p><p>In this article, we will discuss the differences between Level 4 and Level 7 load balancers.</p><h3>Level 4 load balancers</h3><p>Are the most basic type of load balancer, and they focus on the transport layer of the <a href="https://en.wikipedia.org/wiki/OSI_model">OSI (Open Systems Interconnection) Model</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*XmFuf6qOyzrkfwEIyvftKw.png" /><figcaption>OSI Model</figcaption></figure><p>This layer of the OSI is responsible for end-to-end delivery of data packets and includes the physical layer (layer 1), the data link layer (layer 2), and the network layer (layer 3).</p><p>Level 4 load balancers work by inspecting incoming traffic and distributing it across multiple servers based on the source and destination IP addresses, as well as the port number. They are typically employed on web servers, where they are used to spread traffic across multiple web servers and ensure that each one is utilized efficiently.</p><h3>Level 7 load balancers</h3><p>On the other hand, operate at the application layer of the OSI model. This layer is responsible for establishing communications between applications, and level 7 load balancers take this one step further by inspecting the application data in the packet.</p><p>This allows them to make more intelligent routing decisions, such as routing requests to specific application servers based on the URL and/or the type of data in the packet.</p><p>This is why level 7 load balancers are often used for content-based routing, such as directing specific types of web traffic to specific application servers.</p><h3>Overview</h3><p>Level 4 load balancers operate at the transport layer of the OSI model and are used to spread traffic across multiple servers based on source and destination IP addresses and port numbers. Level 7 load balancers, on the other hand, operate at the application layer and are used to better direct traffic based on the application data contained in the packet. Both types of load balancers are essential for ensuring maximum performance and reliability of large-scale network infrastructures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f9ebc2b393" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/level-4-vs-level-7-load-balancers-4f9ebc2b393">Level 4 vs Level 7 Load Balancers</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IDS, IPS and WAF Walk Into a Bar]]></title>
            <link>https://medium.com/swlh/ids-ips-and-waf-walk-into-a-bar-e44bf46d709f?source=rss-f02d23bf56d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e44bf46d709f</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[intrusion-detection]]></category>
            <dc:creator><![CDATA[Rok Nemet]]></dc:creator>
            <pubDate>Mon, 12 Dec 2022 15:36:00 GMT</pubDate>
            <atom:updated>2024-02-27T19:43:12.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E8D_rgmmSBFx-ons" /><figcaption>Photo by <a href="https://unsplash.com/@1walter2?utm_source=medium&amp;utm_medium=referral">Johann Walter Bantz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Bartender asks, what brings you guys here?</p><p><em>We came for the network security breach…</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*6s3sOxBCj6j5ySwVpkAZvQ.gif" /></figure><p>Intrusion detection and prevention systems (IDS/IPS) are a combination of hardware and software solutions that work together to detect and prevent malicious activity on a network. These systems are designed to monitor traffic, detect suspicious activity, and alert administrators when a potential attack is occurring. In addition to these primary functions, IDS/IPS can also be used to block malicious traffic, restrict access to resources, and provide detailed reporting.</p><h3>Intrusion Detection System</h3><p>IDS is a tool for monitoring and analyzing network traffic for suspicious activity. It does this by looking for patterns in the network data that are indicative of malicious behavior. The IDS can detect known malicious activities, such as a port scan, as well as unknown activities, such as a zero-day attack.</p><h3>Intrusion Prevention System</h3><p>IPS is a tool for blocking malicious traffic from entering or leaving a network. It does this by comparing incoming traffic to a predefined set of rules and blocking any traffic that matches those rules. The IPS can be configured to block known malicious activities, such as a port scan, as well as unknown activities, such as a zero-day attack.</p><h3>Web Application Firewall</h3><p>WAF is a tool for protecting web applications from attacks. It does this by monitoring and filtering incoming traffic to the web application, looking for suspicious requests that may be attempting to exploit the application or gain access to sensitive data. The WAF can be configured to block known malicious activities, such as a SQL injection attack, as well as unknown activities, such as a zero-day attack.</p><h3>Summary</h3><p>IDS/IPS is a combination of hardware and software solutions that work together to detect and prevent malicious activity on a network.</p><p>An IDS detects and alerts administrators to suspicious activity, while an IPS blocks malicious traffic from entering or leaving a network. A WAF monitors and filters incoming traffic to a web application, looking for suspicious requests that may be attempting to exploit the application or gain access to sensitive data.</p><p>Together, these tools can provide an effective security solution for any network.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e44bf46d709f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/ids-ips-and-waf-walk-into-a-bar-e44bf46d709f">IDS, IPS and WAF Walk Into a Bar</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why CQRS]]></title>
            <link>https://medium.com/swlh/why-cqrs-6ed13ca999a1?source=rss-f02d23bf56d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ed13ca999a1</guid>
            <category><![CDATA[cqrs]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[cqrs-pattern]]></category>
            <dc:creator><![CDATA[Rok Nemet]]></dc:creator>
            <pubDate>Sun, 11 Dec 2022 19:07:37 GMT</pubDate>
            <atom:updated>2022-12-11T19:07:37.737Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KnhPxXrVUYZn4e6e" /><figcaption>Photo by <a href="https://unsplash.com/@bdchu614?utm_source=medium&amp;utm_medium=referral">Brendan Church</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>CQRS stands for Command Query Responsibility Segregation. It is an architectural pattern that separates the read and write operations in an application. This is done to improve scalability, performance, and overall stability of the system.</p><h3>Standard vs. CQRS Way</h3><p>In a traditional application, both read and write operations are handled by the same code and database. This can lead to bottlenecks and poor performance. CQRS allows us to separate the read and write operations into two different systems. This way, each system can be optimized for its specific task and the overall performance of the application will be greatly improved.</p><p>Let’s look at an example to understand CQRS better. Consider a simple web application that allows users to search for information. In a traditional application, the search query would be sent to the database and the results would be returned. This means that the write and read operations are both handled by the same code and database.</p><p>On the other hand, with CQRS, the search query is sent to the separate read-only system. This system is optimized for searching and retrieving data quickly. The result set is then sent back to the user. In the meantime, the write operations such as creating or updating records are handled by the separate write-only system. This system is optimized for writing and updating records efficiently.</p><h3>The Advantages</h3><p>The main advantage of CQRS is that it allows for more efficient scalability and performance. By separating the read and write operations into different systems, each system can be scaled and optimized independently. This way, the read operations can be optimized for faster retrieval of data, and the write operations can be optimized for creating and updating records quickly.</p><p>Another benefit of CQRS is that it reduces complexity in the system. By separating the read and write operations into different systems, the code is simplified and the overall system becomes easier to maintain.</p><h3>Conclusion</h3><p>CQRS is an effective way of improving scalability, performance, and overall stability of an application. It allows for efficient scalability by separating the read and write operations into different systems. It also simplifies the code and makes the system easier to maintain.</p><p>Therefore, if your application requires high scalability and performance, then CQRS is definitely worth considering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ed13ca999a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/why-cqrs-6ed13ca999a1">Why CQRS</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MySQL Isolation Levels Explained]]></title>
            <link>https://medium.com/swlh/mysql-isolation-levels-explained-718602cfd1e6?source=rss-f02d23bf56d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/718602cfd1e6</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Rok Nemet]]></dc:creator>
            <pubDate>Sat, 10 Dec 2022 15:58:11 GMT</pubDate>
            <atom:updated>2022-12-10T15:58:11.141Z</atom:updated>
            <content:encoded><![CDATA[<h3>MySQL Isolation Levels in 2 Minutes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nu_DrSKvJQcssg83Yd1kaQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/ja/@hharritt?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Hunter Harritt</a> on <a href="https://unsplash.com/s/photos/data?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>MySQL Isolation Levels are a set of rules that determine how different transactions occurring in a database system interact with each other. This is important to ensure that data remains consistent and secure. It also helps to prevent errors and data corruption.</p><p>MySQL Isolation Levels are divided into four categories: <strong>Read Uncommitted</strong>, <strong>Read Committed</strong>, <strong>Repeatable Read</strong>, and <strong>Serializable</strong>.</p><p>Each level provides a different degree of isolation and is used depending on the type of transaction being performed.</p><p>Let’s look at each of them from the lowest to the highest level.</p><h3>Read Uncommitted</h3><p>Is the lowest level of isolation and is generally used when data retrieval is the only operation being performed. This level allows dirty reads, which means that the data being read has not yet been committed to the database. This can result in data inconsistency, as the data may be changed in the meantime. It is not recommended for transactions that require data integrity.</p><h3>Read Committed</h3><p>Is the next level of isolation and is typically used for transactions that require data integrity. It prevents dirty reads and ensures that data being read is committed to the database. However, it does not protect against non-repeatable reads, which means that the same data may be read twice and the values may differ.</p><h3>Repeatable Read</h3><p>Provides an increased level of isolation and prevents both dirty reads and non-repeatable reads. This level ensures that the same data will be read from the database every time and that no other transactions can modify the data until the transaction is complete.</p><h3>Serializable</h3><p>Is the highest level of isolation and prevents any other transactions from reading or modifying data until the current transaction is complete. This level provides the greatest data integrity, but it can also lead to deadlock situations, where multiple transactions are waiting for each other to finish.</p><h3>Still confusing? Don’t worry!</h3><p>To illustrate how these isolation levels work, consider a banking system. Suppose a customer is transferring money from one account to another. In this case, it is important to ensure that the data remains consistent and secure. Therefore, the transaction should be performed at a Serializable isolation level, which will prevent any other transactions from reading or modifying the data until the transfer is complete.</p><h3>Conclusion</h3><p>MySQL Isolation Levels are an important part of database management. Different isolation levels provide different levels of data security and consistency, and the appropriate level should be chosen based on the type of transaction being performed. By ensuring that data remains consistent and secure, MySQL Isolation Levels help prevent errors and data corruption.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=718602cfd1e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/mysql-isolation-levels-explained-718602cfd1e6">MySQL Isolation Levels Explained</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Easy Steps to Manage Your Expectations Like a Pro]]></title>
            <link>https://roknemet.medium.com/5-easy-steps-to-manage-your-expectations-like-a-pro-as-a-junior-developer-ecaf5e1b3d24?source=rss-f02d23bf56d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecaf5e1b3d24</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[managingself]]></category>
            <category><![CDATA[expectations]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Rok Nemet]]></dc:creator>
            <pubDate>Fri, 09 Dec 2022 20:04:21 GMT</pubDate>
            <atom:updated>2022-12-09T22:09:25.429Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 Easy Steps to Manage Your Expectations Like a Pro (as a junior developer)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-YTYqxpRQIvPCoQpDsa44Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@bmowinkel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Brandon Mowinkel</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>As a developer, it is essential to understand and be able to articulate the capabilities and limitations of the technology, as well as the timeline for the project. Being able to set realistic expectations and manage them is one of the most important skills for a successful career.</p><h3>Step 1: Understand Your Role</h3><p>As a junior developer at a new company, it is important to have a clear understanding of what your role is. You should have a clear understanding of your responsibilities, duties, and expectations.</p><p>This will help you to manage expectations and ensure you are meeting the goals of the company. Knowing your role will also help you to understand the scope of the project and the timeline for completion.</p><h3>Step 2: Set Realistic Goals</h3><blockquote>“A goal without a plan is just a wish.”</blockquote><blockquote>— Antoine de Saint-Exupéry</blockquote><p>It is important to set realistic goals for yourself as a junior developer. Setting overly ambitious goals can lead to disappointment and frustration, as it can be difficult to meet these goals. Instead, set goals that are achievable and that will help you to improve your skills and gain experience.</p><h3><strong>Step 3: Communicate</strong></h3><blockquote>“Good communication is the bridge between confusion and clarity.”</blockquote><blockquote>-Unknown</blockquote><p>Communication is key when it comes to managing expectations. Make sure to communicate with your supervisor, colleagues, and clients about any issues or concerns that arise. This will ensure that all parties are on the same page and that expectations are clear.</p><h3>Step 4: Be Flexible</h3><p>As a junior developer, it is important to be flexible and willing to adjust to changing circumstances. While it is important to stay focused on the project, it is also important to be open to new ideas and different approaches.</p><h3>Step 5: Ask For Help</h3><blockquote>“Strength isn’t about being able to go it alone, it’s about knowing when to ask for help.”</blockquote><p>Don’t be afraid to ask for help if you need it. As a junior developer, it is important to recognize when you need assistance and to be willing to reach out to colleagues or supervisors for advice or guidance. Asking for help can be a great way to manage expectations and ensure that the project is completed in a timely manner.</p><h3>Conclusion</h3><p>Managing expectations as a developer is not always easy, but it is an essential skill to have. By understanding your role, setting realistic goals, communicating effectively, being flexible, and asking for help when needed, you can ensure that you are meeting the expectations of your company and that you are on track for success.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecaf5e1b3d24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stack Traces in 3 Minutes]]></title>
            <link>https://medium.com/swlh/stack-traces-in-3-minutes-ffcd0f9cd35c?source=rss-f02d23bf56d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffcd0f9cd35c</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[stacktrace]]></category>
            <category><![CDATA[debug]]></category>
            <dc:creator><![CDATA[Rok Nemet]]></dc:creator>
            <pubDate>Thu, 30 Apr 2020 21:57:23 GMT</pubDate>
            <atom:updated>2022-12-09T20:34:26.772Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SsZhPtSn7KeRvLEE2BLSRw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@crawford?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Crawford Jolly</a> on <a href="https://unsplash.com/s/photos/stack?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>As a developer, you will inevitably run into a stack trace daily. You know what I am talking about a bunch of lines stacked on top of each other with one looking more mysterious than the next. What the hell does it mean and where do we start decrypting this maze of seemingly unrelated text?</p><p>Well, fear no more. In this bite-sized article, I will explain just that.</p><h4>Stack trace, what?</h4><p>The PHP interpreter keeps track of every function executed at runtime by writing to a data structure called a stack. When a function is called it is added to the top of the stack and when the function finishes the interpreter removes it from the top of the stack.</p><blockquote>A stack is a data structure where insertion and removal of items take place at the top of the stack. A basic stack implementation is also known as LIFO — Last In First Out</blockquote><p>You can think of a stack trace as a manifest, a log of functions an application executed up to the point of failure. It will include information like the function name, filename, class name, line number,… where the interpreter thinks the error occurred. This allows us to re-trace steps the application took to identify the problem which caused the exception.</p><blockquote>A stack trace does not include every function an application called before an error, rather it includes only a chain of functions called at the time the error occurred</blockquote><h4>How to read a stack trace</h4><p>For our demonstration let us use a nonsensical example of a class for a Poker game.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70e003a6a5b727bf99ef5e8a86ff6a1f/href">https://medium.com/media/70e003a6a5b727bf99ef5e8a86ff6a1f/href</a></iframe><p>The following code will throw an exception which will produce the following stack trace.</p><pre>PHP Fatal error:  Uncaught Error: Call to undefined function shufflr() in /Projects/StackTrace/index.php:16</pre><pre>Stack trace:<br>#0 /Projects/StackTrace/index.php(29): Poker\Deck-&gt;_shuffle()<br>#1 /Projects/StackTrace/index.php(33): Poker\Deck-&gt;deal()<br>#2 {main} thrown in /Projects/StackTrace/index.php on line 16</pre><p>In the first line, we will see a type of an error that occurred, why it occurred as well as file and line where it happened.</p><p>The following lines show the number of function calls executed before an exception was thrown.</p><p>It is very important to <strong>read the stack</strong> in reverse <strong>from the bottom up</strong>.</p><p>This way we can see that the program executed a {main} function which called a <strong>deal</strong> function which called the <strong>_shuffle</strong> function at which point an execution was interrupted by a thrown exception.</p><p>If we trace the execution path combined with our trace knowledge, we will see that the error occurred on line 16 due to a typo in a method name inside the <strong>_shuffle </strong>function, which is also our last function call in the stack trace.</p><p>Please note that the stack trace includes <strong>only the chain of functions leading to an exception</strong>.</p><p>You can see this behavior by looking at the <strong>deal</strong> function where a private function <strong>_log </strong>was called along with the <strong>_shuffle</strong> function however as the _log function returned the interpreter removed it from the top of the stack and is thus not included in the chain leading up to the exception.</p><h4>Conclusion</h4><p>That is it. Let us quickly summarize what we have learned</p><ul><li>A stack trace is a list of functions called up to the point of an error</li><li>Stack trace should be read from the bottom up</li><li>A stack is a data structure where insertion and removal of items takes place at the top of the stack</li></ul><h4>Bonus</h4><p>Some people like their errors as verbose as possible while others prefer them short and condensed.</p><p>Whatever your preference is a stack trace output can be easily modified per your needs by utilizing the <strong>set_exception_handler </strong>method, i.e.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/235b286c807c6de678e5c9f8cba89b16/href">https://medium.com/media/235b286c807c6de678e5c9f8cba89b16/href</a></iframe><p>This will produce an output similar to the following</p><pre>Exception: Call to undefined function shufflr()<br>Origin: /Projects/StackTrace/index.php on line 16</pre><pre>=========<br>/Projects/StackTrace/index.php deal [55] <br>/Projects/StackTrace/index.php _shuffle [30]</pre><p>The next time you encounter a stack trace you can now confidently approach it head on.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffcd0f9cd35c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/stack-traces-in-3-minutes-ffcd0f9cd35c">Stack Traces in 3 Minutes</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Setup Development Environment with Docker, Xdebug and PHPStorm]]></title>
            <link>https://medium.com/swlh/how-to-setup-development-environment-with-docker-xdebug-and-phpstorm-62a0a4ac482d?source=rss-f02d23bf56d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/62a0a4ac482d</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[xdebug]]></category>
            <category><![CDATA[development-environment]]></category>
            <category><![CDATA[phpstorm]]></category>
            <dc:creator><![CDATA[Rok Nemet]]></dc:creator>
            <pubDate>Thu, 26 Mar 2020 11:55:41 GMT</pubDate>
            <atom:updated>2022-12-09T20:36:00.441Z</atom:updated>
            <content:encoded><![CDATA[<h3>Development Environment with Docker, Xdebug and PHPStorm</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jt6PqiUjaQ-uGajctUzmoQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@altumcode?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">AltumCode</a> on <a href="https://unsplash.com/s/photos/developer-setup?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>The biggest “problem” in today’s development arena, especially for beginners, is the amount of noise present on the web which makes figuring out even the basics of a subject a herculean task. This especially holds for subjects that are extremely prone to subjective needs. One of those subjects is a development environment.</p><p>There is a myriad of technologies and each belongs to at least one interwoven stack or more. I’m sure you have stumbled on your fair share of acronyms (such as MEAN, MERN, LAMP, LEMP,…) while looking for an answer only to find your self discouraged and ready to give up.</p><p>The development environment is by far one of the most overlooked areas yet one of the pinnacles of productivity when it comes to developing software. Most people stop at their choice of IDE and usually a <a href="https://www.vagrantup.com/">vagrant</a> box. They remain in their comfort zone — sometimes for years.</p><p>While I am not advocating against this approach if it works for you, I do believe going just a step further will benefit you profoundly in the long run.</p><p>In this post, we will look at how I set up my basic development environment when working on a project.</p><p>While the examples here are specific to PHP this approach can easily be tailored to your specific needs.</p><p>For this post I will assume you are comfortable with Docker basics, specifically writing a <a href="https://docs.docker.com/engine/reference/builder/">build script</a> and <a href="https://docs.docker.com/engine/reference/commandline/container_run/">running a container</a>.</p><h3>THE GOAL</h3><p>Our goal is to set up a development environment that will allow us to quickly start developing while also giving us enough flexibility to change the technology stack as needed.</p><p>Let us pretend we have to develop an agnostic PSR-4 composer package which needs to calculate the average CO2 emissions over an area in a custom time frame.</p><p>With this requirement set we know we will need to develop on a server (apache, ngnix, caddy, …) with support for a PHP interpreter and a few extensions and libraries (curl, composer…) as well as <a href="https://xdebug.org/">xdebug</a> for debugging and enhanced native error capabilities of PHP.</p><h3>BUILDING THE BASE DOCKER IMAGE</h3><p>We will begin by building our base Docker image on which our environment will be based upon. I prefer to branch my images off of official maintainer images where ever possible.</p><p>Create a file named <strong>Dockerfile</strong> and copy the following instructions</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c821688a21023391b47cb938860c315f/href">https://medium.com/media/c821688a21023391b47cb938860c315f/href</a></iframe><blockquote><em>Official PHP docker image includes a set of helpers (</em><strong><em>docker-php-ext-enable</em></strong><em>, </em><strong><em>docker-php-ext-install</em></strong><em>, </em><strong><em>docker-php-ext-configure)</em></strong><em> which make it easy to install, enable and configure PHP extensions inside the Docker container.</em></blockquote><p>We can now build our base development environment docker image</p><pre>&gt; docker build -t base-dev-image:v1.0.0 .</pre><h3>SETTING UP PHPSTORM</h3><p>Our base image is now ready. Open PHPStorm and create a new project. In the root of the project create a new compose file <a href="https://docs.docker.com/compose/"><strong>docker-compose.yml</strong></a> with the following content</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/433bbaf95d4702313c6c6a8ec404238b/href">https://medium.com/media/433bbaf95d4702313c6c6a8ec404238b/href</a></iframe><blockquote><strong>host.docker.internal</strong> is a special DNS name which resolves to the internal IP of the host. This allows Xdebug to communicate with the IDE.</blockquote><p>Open PHPStorm preferences and select <strong>Build</strong>, <strong>Execution</strong>, <strong>Deployment</strong> section. In the sub-menu, choose <strong>Docker</strong> and click the <strong>+</strong> icon to add new Docker integration and then close the configuration panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NRpup6fjCle4BE7FRhDDZw.png" /><figcaption>Docker configuration panel PHPStorm</figcaption></figure><p>Right-click on the docker-compose.yml file we have just created and select <strong>Create ‘docker-compose.yml’ run configuration</strong>. This will open a popup with additional configuration options. At this point choosing a user-friendly name should suffice. Let’s name it <strong>START DEV ENV</strong> and click apply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FnBKh45z8b3h-_V2ZOL2uA.png" /></figure><p>This will create an entry in the quick configuration drop-down in the main toolbar (<strong>view -&gt; appearance -&gt; Toolbar</strong>). Make sure it is selected and press the run icon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hmXZIVWxyrwcyQoP6llVfA.png" /><figcaption>Main PHPStorm window</figcaption></figure><p>We now have our development server running. Before we continue let’s make sure our xdebug server can communicate with the client. Choose <strong>RUN</strong> from the main menu and choose <strong>Web Server Debug Validation</strong>.</p><p>Fill out proper information and click the. <strong>validate</strong> button. If you followed along the validation should pass.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTYGH9aGbgsJUa0Ur64iow.png" /><figcaption>Xdebug validation panel PHPStorm</figcaption></figure><blockquote>If you see the “Debug protocol ‘’ is not supported” message at the end of validation you can safely ignore it. Before Xdebug 2.9 you could specify a debug protocol. As Xdebug only supports DBGp protocol this option was redundant and has since been removed.</blockquote><p>We are almost done. Let’s create an <strong>index.php</strong> with the following script</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd2370447d40fb3854254710079055b0/href">https://medium.com/media/bd2370447d40fb3854254710079055b0/href</a></iframe><p>Set a breakpoint on <strong>line 8 </strong>and enable the debugger listener on the main toolbar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHmhbKDh6srDjbFUcVjKlQ.png" /></figure><h3>BROWSER SETUP</h3><p>Open the browser of your choice and download an extension which will allow you to easily enable/disable debugging sessions.</p><p>Here are extensions I use:</p><ul><li><strong>Firefox</strong> —<a href="https://addons.mozilla.org/en-US/firefox/addon/xdebug-ext-quantum/"> Xdebug-ext</a></li><li><strong>Chrome</strong> — <a href="https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc">Xdebug helper</a></li></ul><p>Once installed set the <strong>IDE KEY</strong> of an extension to match the name we set in our docker-compose.yml <strong>XDEBUG_CONFIG</strong> section. In our case it’s called <strong>PHPSTORM</strong>.</p><p>Visit the <a href="http://localhost:8000/"><strong>http://localhost:8000</strong></a><strong> </strong>you should see the output from our index.php script. Enable the debug section on your plugin and reload the page.</p><p>Go back to the PHPStorm where you should now see a request to accept a debugging connection. Once accepted you will be presented with the execution state of the script at the point of a set breakpoint .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5j-m8Mu-gFn6ykEIcxWxuA.png" /></figure><p>Congratulations! You now have a working development environment which you can easily replicate for any of your projects.</p><h3>CONCLUSION</h3><p>This setup is very basic and will serve you well for quick projects as a starter template.</p><p>The beauty of containerization is the ease with which you can tailor your environment to your needs. If job requirements change you can quickly update your docker-compose.yml with additional components, re-run the environment from inside the PHPStorm and voilà.</p><p>No need for Infrastructure management software, no manual apt/apk/yum installs, no cumbersome configuration and most importantly no time lost.</p><p>Hopefully, this post will provide you with a solid base on how to connect Docker, xdebug and PHPStorm.</p><p>If you have any tips, tricks or comments please feel free to share them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62a0a4ac482d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-to-setup-development-environment-with-docker-xdebug-and-phpstorm-62a0a4ac482d">How to Setup Development Environment with Docker, Xdebug and PHPStorm</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero downtime master/slave replication]]></title>
            <link>https://medium.com/swlh/zero-downtime-master-slave-replication-4f2814138edf?source=rss-f02d23bf56d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f2814138edf</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[percona]]></category>
            <category><![CDATA[xtrabackup]]></category>
            <category><![CDATA[dba]]></category>
            <category><![CDATA[replication]]></category>
            <dc:creator><![CDATA[Rok Nemet]]></dc:creator>
            <pubDate>Mon, 07 Oct 2019 07:47:30 GMT</pubDate>
            <atom:updated>2020-12-02T14:49:23.084Z</atom:updated>
            <content:encoded><![CDATA[<h3>Zero downtime MySQL master/slave replication with Percona</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bVL1pEDhuHS2cjayg7YTA.png" /><figcaption>MySQL Master/Slave Replication Flow</figcaption></figure><p>I was recently approached by a provider of analytical and real-time fraud management solutions for the telecommunication industry after the fire in the data centre wiped out their database cluster. The incident left the analytical side of the business inoperable for days but luckily the master node survived.</p><p>At this point, I was presented with a challenge to re-establish a <strong>Master -&gt; Slave</strong> setup without taking the master node offline.</p><h3>The problem</h3><p>To understand why this is a challenge, we need to look at how MySQL handles its replication on a high level.</p><p>At the gist of it, there is a <strong>binary log</strong> a special log file to which the Master node writes to through a <strong>dump thread</strong> and contains information on all data modifications made to a database instance.</p><p>When the slave node connects to the master node it will open two connections:</p><p><strong>IO Thread</strong> — a process that receives a binary log sent by the master which is then copied over to a local log file called a <strong>relay log</strong>.</p><p><strong>SQL Thread</strong> — a process that continuously reads the relay log and applies the changes to the slave node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bVL1pEDhuHS2cjayg7YTA.png" /><figcaption>MySQL Master/Slave Replication Flow</figcaption></figure><p>At the beginning of replication, the slave needs to be told from what binary log position it should start replicating the events from. This point is called a <strong>master log position</strong> and serves as coordinates at which the slave I/O thread should begin reading from the next time the thread starts.</p><p>Each change to the database also changes the master log position and since we can’t reliably extract the log position we cannot proceed with the slave setup. If you are coming from the enterprise-grade relational databases like Oracle or SQL server, etc. you are probably used to a <strong>hot</strong> backup.</p><blockquote>A hot backup, also known as dynamic backup is a backup performed on a server while the database is actively running and accessible to users and is a standard way of doing most backups on enterprise-grade solutions.</blockquote><h3>The solution</h3><p><a href="https://www.percona.com/software/mysql-database/percona-xtrabackup">Percona XtraBackup</a> was a perfect candidate for the job. It provides an enterprise type backup feature to a non-enterprise RDS.</p><blockquote><em>The Percona XtraBackup performs online non-blocking, tightly compressed, highly secure full backups on transactional systems so that applications remain fully available during planned maintenance windows.</em></blockquote><h3>The process</h3><p>Setting up a slave for replication with Percona XtraBackup is a very straightforward procedure.</p><p>For the sake of simplicity, I will summarize the steps it took us to create a hot backup and properly re-establish replication on the slave.</p><p>Step #1 — Preparing data</p><p>At first we need to create a backup on the master node. We do so by executing the following command into a shell:</p><pre>$ xtrabackup --backup --user={USERNAME} --password={PASSWORD} --target-dir={PATH_TO_BACKUP}</pre><p>This will create a copy of your MySQL data directory to the directory we specified in the --target-dir option. XtraBackup knows where the current MySQL data directory is by reading the my.cnf. If your configuration file is located in non-standard location you may pass the proper location through --defaults-file=/path/to/my.cnf.</p><p>Once the process finishes with the <strong>xtrabackup: completed OK!</strong> we need to prepare the data for the snapshot to be consistent. We achieve this by executing the following command:</p><pre>$ xtrabackup --user={USERNAME} --password={PASSWORD} --prepare --target-dir={PATH_TO_BACKUP}</pre><p>The process will apply transaction logs to the data files which are now ready to be consumed by the MySQL server.</p><blockquote>Data preparation step ( — prepare) does not need to be executed on a master host you can run it on a slave as well.</blockquote><p>Step #2 — Moving data to the slave</p><p>Now that we have our backup files let’s copy them to the slave.</p><pre>$ rsync -avp --progress /path/to/backup {SLAVE_HOST}:/tmp/backup</pre><p>Once the data is copied to the slave we need to move it to a proper data directory. Before doing so it is advised to backup the current data directory.</p><pre>$ mv /var/lib/mysql /var/lib/mysql-bak</pre><p>Now, let us move the copied back up to the MySQL data directory. You can do this by manually moving the files or if you have Percona XtraBackup installed on the server you may execute the following command:</p><pre>$ xtrabackup --move-back --target-dir={PATH_TO_BACKUP}</pre><p>If you are moving data to a different directory than the system default, make sure you set MySQL as a directory owner.</p><pre>$ chown mysql:mysql /path/to/new/dir</pre><p>Step #3 — Getting binary log file name and master position</p><p>To retrieve a binary log file name and position open the file xtrabackup_binlog_info which is present in the backup directory.</p><pre>$ cat /var/lib/mysql/xtrabackup_binlog_info</pre><pre>// Output<br>master-bin.000001     481</pre><p>In this post, I will not cover the additional setup of replication as I primarily wanted to focus on the solution to the problem. If you wish to learn the basic setup of replication you can <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql">follow the guide at DigitalOcean</a>.</p><p>I would like to finish this post with quote <strong>“Data is the new gold.”</strong> as such we could argue that the core of the modern business is not the product but rather the data it can gather, and keeping it safe should be everyone’s top priority.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f2814138edf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/zero-downtime-master-slave-replication-4f2814138edf">Zero downtime master/slave replication</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>