ugur elveren's blog

I often find my mind wandering to different topics, interrupting phone calls, meetings, or reading sessions. These thoughts take center stage, making it challenging to refocus on the original task.

Interestingly, this mental game sometimes proves helpful. Whether it's a forgotten task during a book or a work-related bug that surfaces while spending time with family, these moments can be both distracting and beneficial.

A peculiar incident occurred last week when, despite my usual preference for organic food, I accidentally purchased non-organic sourdough bread. Initially trying to ignore it after enjoying a slice for breakfast, curiosity led me to search for its ingredients. The search took me down a rabbit hole of articles and comparisons between the European Union and the United States, accompanied by alarming posters like “Stop Eating Cancer.”

Though not a chemistry enthusiast, I felt the need for some chemistry knowledge to navigate ingredient lists. It seemed complex, with some ingredients deemed safe, others unknown, and some linked to health issues.

The idea of a simple barcode reader app solving this mystery crossed my mind. Such an app could provide a safety score for food items. However, existing apps in the market often push for subscriptions or paid versions.

But wait a minute, the government needs to check it for me right?

Maintaining a healthy diet appears to come at a higher cost. Even with organic non-GMO choices, scrutinizing ingredients becomes crucial. It feels like an unwelcome chemistry lesson, requiring the memorization of various terms to ensure the elimination of potentially harmful foods.

Questioning the need for personal scrutiny, I pondered the role of the FDA, a government organization meant to safeguard consumers. However, the approach varies significantly between the US and the EU.

The FDA in the US tends to take a hands-off approach, allowing new food ingredients unless proven harmful. This includes substances like GMOs, growth hormones, and chemical preservatives. In contrast, the European Food Safety Authority (EFSA) mandates safety proof before approving additives and bans certain substances, including growth hormones and various chemicals.

These differing regulatory philosophies result in the approval of certain additives in the US but their prohibition in Europe. Notable examples include growth hormones, ractopamine, potassium bromate, brominated vegetable oil, olestra, azodicarbonamide, and various coloring agents and preservatives.

Armed with this information, I've become more conscious of what I consume, hoping others will do the same. It's a reminder to stay informed about the food we eat for the sake of our health.

#personal #foodSafetly

The circuit breaker pattern stops a service from trying again to call another service when the previous attempts have failed multiple times. It's similar to electrical circuit breakers that automatically cut off the current when there's abnormal activity.

In a distributed environment, calls to remote resources may fail due to reasons such as application exceptions, timeouts, authentication issues, or overloaded systems. Usually, resilient cloud applications automatically fix these issues over time, and the calling application manages these errors using a retry pattern.

However, in some cases, these failures can persist, like when a service is down or systems are consistently overloaded. Excessive retries can create a cascading effect, overloading the same resource and impacting other resources as well. Repeated calls can impact both cost and performance.

At this stage, circuit breaker patterns come into play to address this issue. When the callee retries, it begins to assess the problem. If there's a specific error or if the error count surpasses the limit, circuit patterns activate, breaking the communication between the caller and the callee.

Circuit Pattern Implementation Details

There are three main stages for the circuit breaker pattern.

Closed

In a healthy state, the circuit breaker remains closed. It routes actions from source to target, mainly observing requests and logging their results.

Open

If a specific error occurs in the previous request, such as a service being down or exceeding the error limit, the circuit breaker transitions to the open state. In this state, the circuit breaker prevents the continuation of the request, immediately returning it to the source application.”

Half Open

Half-Open state allows a few requests to test if a system has recovered from a failure before fully reopening. It's like cautiously peeking to see if things are back to normal.

You can use a timer, or more commonly, implement sampling between requests. Sampling involves letting a limited number of requests pass through. This helps evaluate if the system has recovered from a failure before completely reopening the circuit. It's a controlled method to check the system's health without overwhelming it with a full load of requests.

When to use Circuit Breaker Pattern

The circuit breaker pattern serves as a digital guardian for our systems, aiding in various key aspects:

Fault Handling

It prevents the application from attempting to invoke a remote service, particularly when there's a high likelihood of failure. This is crucial when dealing with external services or dependencies that may encounter issues. The circuit breaker helps avoid repeated attempts to use a failing service.

Resilience

If you want your solution to gracefully handle temporary failures, consider implementing the circuit breaker pattern. Depending on your solution, you can trigger different events or take various actions based on the circuit breaker pattern's state.

Load Management

The Circuit Breaker pattern assists in preventing overload on any dependency or system in our solution. This protection is valuable during high traffic or when downstream services are struggling.”

Issues and Considerations

Code Bloating and Complexity

The Circuit Breaker pattern introduces some processing overhead to requests. Handling exceptions and deciding when to open or close the circuit breaker can be complex. Exception handling should be tailored to the specific application, and incorporating third-party dependencies may introduce additional logic into our code or solution. Dealing with exceptions that include error codes might contribute to an increase in code volume. For example, encountering a 404 Not Found error doesn't necessarily imply that the target resource is absent. Depending on the error code, you might need to decide whether to retry or initiate a 5-minute circuit closure. In some cases, developers might include the same error code in their code, and if you encounter a 404 with error code ER-12312, it might not require any action at all.

Observability and Logging

A circuit breaker should record both failed and, if feasible, successful requests in its logs. System administrators should have the ability to monitor the system, and depending on factors such as load or failures, developers or system administrators may need to perform tuning or implement additional measures for optimization.

Force or Manual Override

System administrators should have the capability to manually open or close the circuit breaker. Additionally, having the ability to reset the failure counter or restart the timeout timer can be beneficial for system management.

Bottleneck

The circuit breaker might be accessible across multiple instances of an application. The implementation should not impede concurrent requests. If there is a request counter for the half-open state, it should not create a bottleneck. Additionally, if there is an additional dependency, such as a database or any other data sources, those sources should be scalable to accommodate the potential load.

The cloud is vast. Azure docs have around a hundred thousand pages, and AWS is just as big. Other cloud providers are out there too. Each gives you lots of apps, different rules, and dozens of integrations, so creating cloud-native ones has its challenges.

They're not identical, but big providers offer similar solutions. For example, Google Cloud Storage is like AWS S3 and Azure's durable function is similar to AWS step functions. Details and rules can differ, but the main idea of the tech is similar, along with the challenges.

Because problems are alike, solutions are too. We can group similar solutions and make templates for each group. Like a cooking recipe guides you to a tasty dish, these templates can be our guide to perfect solutions.

What is a design pattern?

In simple terms, a design pattern is a handy, repeatable solution for a common problem in making software. It's not a complete design you can directly turn into code. Instead, it's like a guide or template, describing how to solve a problem that fits various situations in software design.

What is a cloud design pattern?

In simple words, a cloud design pattern is a solution we can use over and over for common issues in cloud computing. People often use these patterns to make things scalable, reliable, and secure in the cloud.

What are the common challenges in cloud development?

Cloud development has lots of benefits. It makes scaling and adapting to market changes easy for organizations. Plus, it offers better reliability and improved disaster recovery. The pay-as-you-go model also cuts upfront costs.

Moreover, the cloud provides easy access to advanced technologies, even without in-house expertise. This allows organizations to automate IT tasks, easing the load on IT teams and giving them more time.

Cloud development has its challenges. Things like keeping things secure, managing costs, making sure it can grow when needed, and connecting different services can be tricky. Organizations need to tackle these challenges.

Let's explore each topic to understand them better.

Scalability

Scaling is a big plus in the cloud. Organizations adjust resources as needed, paying for what they use, keeping costs low and solutions reliable.

However, it's not always smooth. Complex cloud setups, old systems, or not enough know-how can be challenges. These might affect reliability or lead to cost issues.

Before the cloud, there were stories. Like, organizations aired TV commercials in prime time, and after, customers saw an HTTP 500 error on their computers. Not ideal!

Reliability

Cloud providers set up many data centers in different places, so even if one has a problem, others can keep things going. Also, in the cloud, there are backup components ready to jump in if needed.

However, using the cloud often means dealing with systems spread out everywhere. This makes it tricky to handle communication, consistency, and reliability among different parts. While the cloud lets you grow easily, not planning how to grow or sudden high demand can cause problems, affecting how reliable services are.

Even with backup plans, cloud services can go down sometimes. Things like hardware issues, software problems, or even attacks can happen, impacting how well applications work.

Security

Security is important in cloud development for organizations using cloud-based tools. Even though cloud providers give security features, there are still challenges that organizations must tackle to keep their cloud environments safe.

Challenges include data breaches, misconfigurations, and identity management problems. Steps like encrypting sensitive data, having strong access controls, and clear policies are vital to keep the cloud secure.

Data Management

Handling data in the cloud has lots of benefits over on-prem solutions. It lets organizations be more flexible, scalable, and cost-effective. Automated backups and recovery options make sure data stays safe. Also, cloud services often provide advanced analytics tools, helping in extracting valuable insights from the data. Being scalable helps manage big loads of data easily.

But, dealing with data in the cloud comes with challenges. Organizations need to ensure data integrity and address concerns about security, and compliance. Making sure rules about data are the same across different cloud setups can be hard, especially if an organization uses many clouds or a mix of cloud and old-school systems. To keep sensitive data safe, there need to be strong security measures, like controls, encryption, and tools to prevent data loss. Bringing data from old systems or other clouds into the cloud can also be challenging, needing careful planning and syncing.

Integration

Cloud integration brings numerous benefits to organizations, helping them link different apps, smoothen data flows, and enhance overall business processes. It's like having a well-organized toolbox for projects, making things run more smoothly, scalable, and efficient.

While offering numerous benefits, there are challenges. Getting old systems into the mix, especially if they're outdated, needs time and effort. This might mean custom integrations to connect them to cloud apps. Cloud integration also involves linking apps and systems that use different ways of talking and different rules. This can make it hard to map data, ensure things work together, and ensure compatibility, and maintain data integrity during integration. Managing data ownership, governance policies, and data lineage across multiple cloud environments can be challenging as well.

Monitoring

Monitoring cloud operations is crucial in modern cloud development. It gives organizations the info they need to keep things running well, find problems, and make sure everything in their cloud apps and systems is healthy and safe. It's like having a set of eyes always looking out for you.

But, monitoring comes with challenges. Bringing in data from different sources, including cloud systems and external sources, can be complex. Monitoring systems produce a lot of data, leading to alert fatigue and difficulty in identifying critical issues. Plus, monitoring systems themselves need to be secured from unauthorized access and data breaches.

What is Next?

In the next article, I'll explain cloud design patterns one by one. I'll use real-world examples to make things clear. We'll connect each pattern with one of the challenges we talked about. By the end, this will give us more know-how on each topic and a better understanding of the challenges.

#Tech #Cloud #CloudDesignPatterns

In late August, southern California faced a mosquito invasion. These tiny pests seemed to appear out of nowhere, leaving their itchy marks on unsuspecting victims. Whether you had a bug screen or not, they found their way into your home, and you'd wake up with irritating mosquito bites. At first, you might not notice them, but as time passed, the incessant itching would become undeniable.

These mosquitoes were notorious for targeting ankles, leaving small, pink, and itchy bites. Sometimes, you'd wake up with not just one or two but possibly three or more bites. The constant itching would make you want to scratch your ankles, especially when walking. It was nearly impossible to scratch them all the time, like when driving, where you'd long for relief.

By the end of the day, you'd have scratched your ankles raw, and the next day, it would only get worse. Congratulations, you'd have itchy scars and mosquito bites.

After a few weeks, I had to confront the mosquito problem plaguing us. The constant itching was unbearable, and even my precious puppies were not spared. Seeing my dog helplessly bothered by these mosquitoes, I decided it was time to take action.

I began wearing socks before sleeping and opted to use the air conditioner instead of opening windows. It made a difference, and though I still spotted the occasional mosquito, I became adept at swatting them before they could bite. Sleeping in socks and long sleeves also helped.

One day, I had a fantastic night out with friends, celebrating something special. I returned home late, exhausted, and in my tired state, I forgot about the mosquito problem. I kept the window open to enjoy the ocean breeze, and by morning, I was covered in fresh mosquito bites. These pests had taken advantage of my lapse in vigilance.

I realized I needed to confront this problem head-on. Passive measures weren't effective. So, I declared war. I ordered bug zappers and mosquito-killing sprays. Before sleeping, I abandoned socks and long sleeves, choosing instead to check the lights and eliminate any mosquitoes. There were a few nights I forgot, but the bug zappers and previous efforts paid off. It was initially a bit scary and required effort, but I learned that ignoring the problem was more costly. My quality of life improved, and I woke up without disturbances. Occasionally, there were accidents, especially when I ventured outside my “castle.” I went shopping and returned with a couple of bites, but this taught me to be prepared. I learned to identify areas prone to mosquitoes and took precautions with repellent body spray.

The key was accepting that I had a problem, taking proactive steps to combat it, and arming myself with solutions to alleviate the bites during my ongoing battle with these pesky insects.

#mosquitoes #personal

Since the beginning of the pandemic, I've noticed a repetitive pattern of content on the internet across various platforms. Whether it's on Reddit, different social media sites, or news websites and popular blogs, the same or similar content keeps circulating. Additionally, Google searches have taken a peculiar turn. When searching in English, the results often differ from the same websites, and in other languages like Turkish, you might encounter clickbait websites with strong SEO but weak content.

I appreciated the user-friendly interface and the quality of the community on Hashnode. I read some excellent articles. After a few articles, my job changed, and life became busier, leaving me with little time to write more.

In the last few months, I've had some spare time and planned to write more. However, I encountered a hurdle. I realized I didn't need a development-centric blog; I wanted a space to share my thoughts on various topics. Unfortunately, this didn't align with Hashnode's rules, and it would feel out of place among the tech-focused blogs. Consequently, I decided to migrate my blog from Hashnode to Write.as.

Initially, I experimented with hosting my own instance on one of my servers and even on a Raspberry Pi, which turned out to be surprisingly easy. I opted not to use my EC2 instances due to cost concerns. While the Raspberry Pi experiment went well, I didn't want to rely on my home internet to host a blog. So here I am, writing this post with my Write.as account. While I haven't made my first payment yet, I've already updated the CNAME record. After this post, I plan to transfer my old posts from Hashnode and import them into my new blog. I've already exported all my posts to a JSON file, although I'm unsure about the importing process; I'll figure that out after completing this post.

#Writefreely #personal

Azure Functions and Azure Durable Functions

Microsoft Azure is a constantly expanding collection of cloud services. Among these services, Azure Functions and Azure Durable Functions are critical in enabling serverless computing. In this article, we will look at Azure Functions and Azure Durable Functions, distinguish between the two, and learn about the key concepts surrounding Azure Durable Functions.

Read more...

In my previous blog post, I created a script that controls the fan speed on my Raspberry Pi. However, I encountered a problem – every time I restarted my Raspberry Pi, I had to manually run the script again, which was not ideal.

In this blog post, I will demonstrate how to automate the execution of any script using Systemd. Systemd is a system and service manager for Linux operating systems.

There are several methods to run software as a background service in Linux, such as using crontab or .bashrc, among others. If you're interested in those methods, you can easily find more information online.

Read more...

Last week, I did something unplanned: I bought a Raspberry Pi without any specific project in mind. I came across a Mastodon account (@rpilocator@mastodon.social) that helps people locate Raspberry Pis and I decided to get one. And now, here it is! I'm writing my first blog post about the Raspberry Pi Fan Control.

Read more...

Hello there! The prefix sum technique involves creating an array where the prefix[i] is the sum of all elements up to index i. This technique can also be referred to as the cumulative suminclusive scan, or simply scan.

prefix[0] = nums[0]
prefix[1] = nums[0] + nums[1]
prefix[2] = nums[0] + nums[1] + nums[2]
prefix[i] = nums[0] + nums[1]+ nums[2] + .. + nums[i]

For example, if the original array is [1, 2, 3, 4], the prefix sum array would be [1, 3, 6, 10].

Time Complexity

The time complexity of Prefix Sum is O(n) since we need to iterate through the input array once all the items in the array. But after the prefix sum array is computed, we can use it to answer subarray sum queries quickly, in constant time. It allows us to find the sum of any subarray in O(1).

If we want to find the sum of i to j, the answer is prefix[j] - prefix[i] + nums[j];

Problem: Finding subarray sum with Prefix Sum

Given an array nums[] of size N. Given Q queries and in each query given L and R, Print the sum of array elements from index L to R.
Read more...

Window Sliding Technique is a strategy that aims to reduce nested loops for solving problems where you need to analyze a sequence of elements, like an array or a string. The technique reduces the use of a nested loop and replaces it with a single loop, reducing the time complexity.

The sliding window technique is efficient because it avoids unnecessary computations. By moving the window only one step at a time, you avoid repeating calculations already done for the previous window. This can save a lot of time and make the algorithm more efficient.

This approach is useful in solving problems that involve finding a subarray or substring that meets a certain condition, such as the maximum sum of a subarray or the longest substring without repeating characters. By sliding the window over the input sequence, the algorithm can efficiently explore all possible subarrays or substrings and identify the ones that meet the given condition.

The longest sub-array having a sum is less than k.

Given an array of positive integers nums and an integer k, find the
length of the longest subarray whose sum is less than or equal to k.

The problem supposes you have an array of positive numbers and a target number, k. You want to find the longest possible subarray (a contiguous sequence of elements) in the array whose sum is less than or equal to k.

Input: arr[] = { 3, 1, 2, 4, 5, 9 }, k = 10 Output: 4 Explanation: The sub-array is {3, 1, 2, 4}.

Solution

Create a window of elements by moving the right pointer to the right until the desired size or condition is met. If the sum of the elements in the window exceeds the given integer k, we need to adjust the window to the right. We do this by moving the left end of the window one step to the right and subtracting the element that was previously at the left end of the window from current. We repeat this process as many times as needed until the sum of the elements in the window is less than or equal to k.

At each iteration, we update the answer variable with the maximum length of the subarray seen so far. We calculate this as the difference between the current right index and the left index. We continue iterating over the array until we reach the end.

public int FindLengthOfLongestSubarray(int[] nums, int k) {
    int left = 0;
    int current = 0;
    int answer = 0;

    for (int right = 0; right < nums.Length; right++) {
        current += nums[right];
        while (current > k) {
            current -= nums[left];
            left++;
        }
        answer = Math.Max(answer, right - left + 1);
    }
    return answer;
}

Fixed Size Sliding Window

The fixed sliding window problem is a specific type of problem that requires finding a solution within a fixed-size window of elements in an array or sequence. This means that the size of the window remains constant throughout the problem.

The maximum sum of any subarray of size k

Given an array of integers and a fixed window size of k, find the
maximum sum of any subarray of size k.

Solution

To solve this problem using the sliding window technique, we would start by initializing two pointers, left and right, to the beginning of the array. We would then create a window of elements by moving the right pointer to the right by the size of the window.

Next, we would calculate the sum of the elements in the window. We would then store this sum in a variable, say max_sum.

We would then slide the window to the right by incrementing the left and right pointers by one, subtracting the element at the left end of the old window from the sum and adding the element at the right end of the new window to the sum. We would then update the max_sum as necessary by comparing it to the sum of the new window:

public int MaxSumSubarray(int[] arr, int k)
{
    int left = 0;
    int right = k - 1;
    int maxSum = 0;
    int currSum = 0;

    // Calculate the sum of the first window
    for (int i = 0; i <= right; i++)
    {
        currSum += arr[i];
    }
    maxSum = currSum;

    // Slide the window and update the maximum sum as necessary
    while (right < arr.Length - 1)
    {
        currSum -= arr[left];
        left++;
        right++;
        currSum += arr[right];

        if (currSum > maxSum)
        {
            maxSum = currSum;
        }
    }

    return maxSum;
}

Conclusion

In conclusion, the sliding window technique is a useful algorithmic pattern that can be applied to a wide range of problems in which we need to find a subarray or substring of a given array or string that satisfies certain constraints.

The technique involves creating a “window” of a fixed size or a variable size that slides through the input data, with the goal of finding the optimal solution or the longest/shortest subarray/substring that satisfies a specific condition.

Fixed-size sliding window problems are easier to solve as we only need to maintain a window of a fixed size, while variable-size sliding window problems require us to adjust the window size dynamically based on the problem constraints.

Overall, the sliding window technique provides a simple and efficient way to solve a variety of problems, particularly those that involve searching for a continuous subset of data that meets specific criteria.

#Tech

Enter your email to subscribe to updates.