<?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 Boris Janischevsky on Medium]]></title>
        <description><![CDATA[Stories by Boris Janischevsky on Medium]]></description>
        <link>https://medium.com/@bajani2007?source=rss-c23427067b22------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IrOyYNR14vmdjMb1xDH3OQ.png</url>
            <title>Stories by Boris Janischevsky on Medium</title>
            <link>https://medium.com/@bajani2007?source=rss-c23427067b22------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 13:12:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bajani2007/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[How I met Robert Duvall and got his autograph]]></title>
            <link>https://medium.com/@bajani2007/how-i-met-robert-duvall-and-got-his-autograph-51b533b9c632?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/51b533b9c632</guid>
            <category><![CDATA[robert-duvall]]></category>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Wed, 19 Aug 2026 19:05:40 GMT</pubDate>
            <atom:updated>2026-08-20T13:42:06.049Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<p>Haven’t written anything in a while, a writer’s dry spell perhaps? <br>So I remember seeing in the news that Robert Duvall passed away in February this year (2026), and I recalled I was travelling from Washington DC back to Buenos Aires in 2007, where I recognized him sitting on the airport and I asked him for his autograph. Was it Dallas? Can’t tell anymore, that was a long time ago. He was sitting right next to (I thought so) his wife and I did what any movie stars fan would do. No, no camara, no embarassing chit chat, I wanted to be a more subtle than that. Why? Not sure, I had recently seen “Assasination Tango”, while I was still living in Canada around 2006, so his name stuck in my mind.</p><p>So I decided not to engage him directly, nor his wife to avoid embarrasing them and I played a little scene where my back-pack fell to the floor and I suddenly dropped a pouch with all my travelling documents too. They were sitting about 3 feet away from me. When I was collecting my stuff again, I looked at them and said “you are not Robert Duvall, right ?” , so that started the conversation. Subtle? not sure, but hey I deserve an Oscar too :-)</p><p>So I introduced myself, explained I was living in Canada, moved back to Argentina, that I remembered seeing “Assasination Tango” recently, he was surprised I liked it, perhaps because it wasn’t a hollywood blockbuster, but since I am Argentinean it made me shed a tear and remember home. His wife smiled at the time, so I bet his wife who is also Argentinean was an influence to him for making that movie. And that’s pretty much how the conversation ended, I didn’t want to bother them too much.</p><p>Sharing the autograh below. It’s a piece of history of one of the greatest actors in some of the greatest movies of an era.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6MESt5YVPRRnG_aI-s4pIA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51b533b9c632" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A short story of how NASA helped me with a software project in the late 90s]]></title>
            <link>https://medium.com/@bajani2007/a-short-story-of-how-nasa-helped-me-with-a-software-project-in-the-late-90s-178897436c51?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/178897436c51</guid>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Wed, 16 Apr 2025 21:23:30 GMT</pubDate>
            <atom:updated>2026-05-15T01:35:03.931Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8zjyEazMNkXSE4gu" /></figure><p>This story has no technical value in 2025, it’s literally ancient history, nevertheless it is a funny anecdote I wanted to share.</p><p>I remember I was finishing university in 1997, but was working as a contractor for a few companies in Buenos Aires, Argentina. I had several companies running applications developed by me in Visual Basic, C/C++, Clipper, FoxPro, SQL Server, MS Access….. I enjoyed working with different technologies and industries and constantly learning new things.</p><p>That year, somebody from my university gave my name to a company that sold Dolphin hand-held bar-code readers. These were hand-held devices running MS-DOS, with an attached bar-code reader. Very basic hardware, but very sturdy for rugged environments.</p><p>They looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*5JrtDtCv1nABe4yU9RzQLw.png" /></figure><p>The picture shown here is of the “Hand Held Dolphin 7200 Mobile Computer” that is discontinued and replaced by more modern versions. You can still find them in some barcode hardware e-stores.</p><p>I was contacted by their engineering manager, who told me their business focus was selling the hardware, not developing custom applications running on these devices. However, they ended up developing apps themselves for their customers, but it wasn’t their forte. So, they asked me to become their contractor to take over these jobs.</p><p>I ended up working for them a few years, the applications were relatively simple, a few screens, capturing data on text files and normally uploading them with z-modem file transfer over to another computer. These were days where http, ftp, Tcp/Ip and Wifi wasn’t wide spread within industrial environments, so many of these apps were offline apps that needed to sync data when docked and connected to other computers.</p><p>So how did NASA help me? Well, it all started when requirements got a bit fancier in the apps I was developing on these hand-held devices. I had to be able to locate products within a 10K records text file as quickly as possible (just remember this was an 386sx processor with 640KB of RAM). I recalled seeing people in the early 90s working with QuickBasic and a BTrieve Library, but couldn’t find that specifically until I came across a free library written in Berkeley University. This was an indexer library for flat files written in ANSI C that I could simply compile in my projects and use it to update and query a binary tree index file that would give me a pointer to a record in a main file with data. And the library was free to use, so everything added up. I started using it in a project with around 2 to 3K rows in a file and everything went fine, it was fast and it seemed stable. I also checked which companies were using it, didn‘t find too many references on the internet, neither at Berkeley university itself, but I found the user’s manual on the NASA web site. I found it using Altavista search engine, it was just another page somewhere on the main NASA website. Well, if NASA uses it, I guess it wass enough proof this is a viable library for me to use.</p><p>So I delivered the project, nothing out of the ordinary. Collected my payment, customer was happy, life was good. But one week later, my customer calls me telling me that their customer is having trouble with files larger than 10K records. It wasn’t a storage problem, it was a bug in the code, it was the binary tree library failing.</p><p>Desperate, because in the end this was a library with zero support from anyone, I started digging on the internet and maybe contact the author of the library. No response from Berkeley. Until I did the unexpected, went to the NASA site and sent an email to the regular info@… all-purpose / catch-all email address and asked them for any guidance they could provide using this library.</p><p><strong>HATS OFF for NASA,</strong> I received a response 24 hours later, asking me what version of this library I was using, I told them something around 0.4x and they replied again that they are using v2.x. and that those earlier 0.4x versions were all error prone and buggy, they were even so kind to send me the code of v2 as well. Then I simply compiled the app for my customer and everything started to work fine.</p><p>I learnt two lessons with all this, first: test your apps in a serious way, especially when you are introducing 3rd party untested code. And second: don’t be afraid to ask for help, even if you have to ask one of the biggest scientific organizations in the world that have absolutely no responsability or part in whatever business you are doing. A lesson of humbleness, optimism and resilience I’d say.</p><p>Thank you for reading, hope you enjoyed this short story.<br>Boris</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=178897436c51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Quicksight — a comprehensive introduction]]></title>
            <link>https://medium.com/@bajani2007/aws-quicksight-a-comprehensive-introduction-13abe646b5dd?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/13abe646b5dd</guid>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[reporting-software]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[amazon-quicksight]]></category>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Tue, 12 Nov 2024 11:46:40 GMT</pubDate>
            <atom:updated>2024-11-16T00:28:06.856Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<h3>AWS Quicksight — a comprehensive introduction (2024Q3)</h3><p>I had the opportunity of working with AWS Quicksight (QS) for several months. My job was to define guidelines and standards on how to embed dashboards on webpages. I started from scratch, never used it and I hadn’t used anything similar in ages. This article contains a summary of everything I learned in the process.</p><h4>What is AWS Quicksight?</h4><p>Some will call it an analytics, business intelligence or a reporting tool. All of the above is correct, but in essence it’s an application that is part of Amazon’s cloud offering that will allow you to generate visual representations of data on web pages or PDF files, that’s it.</p><h4>What data sources can I use?</h4><p>It can consume virtually anything available on AWS. I haven’t seen anything that allows you to connect to external data sources, but if it’s in your AWS account, you can pretty much read it and display it.</p><h4>How does the development process work?</h4><ol><li>You start by defining a data source which can be files, databases, etc.</li><li>Then you define a query on this data source and save it as a dataset.</li><li>Once you have that, you create an analysis which is a graphical design for displaying the data and then you publish it as a dashboard <strong>*1📝</strong> .</li></ol><p>A dashboard is a web page or html part that can be embedded in another web page or shared with other users. All QS objects can be shared among all QS users for editing or reading, so if you have a team of editors you can improve productivity by sharing objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*77ZS5fclB4dVM0OU30dpVw.png" /><figcaption>The main quicksight development page</figcaption></figure><p><strong>*1</strong>📝A dashboard is a confusing term here, because a dashboard implies some sort of a board with many indicators, charts or reports, that measure one or many processes. So in terms of QS, a dashboard is basically a published set of visuals, containing one or many variables being displayed for analysis purposes. The sources of data can also be multiple. Every visual is a type of chart, e.g. bars, pie, lines, dots, areas, etc.</p><p>A very good feature is the mapping of parameters between analyses and datasets. Every dashboard can have html controls with inputs (textboxes/dropdowns/date pickers) where the user can enter or select text, that can be used as data filters. These filters can then be mapped to analysis parameters which in turn can be mapped to dataset parameters. Parameters can default to empty values, constants or functions, so for example you can define a start-date which can be the beginnig of the current month and an end-date parameter that defaults to today. If the control is mapped to the parameter the user will be have the option to change the values. Parameter values can also be passed from the hosting page when embedding a dashboard, more on that later. <br>The good thing is that these filters can be applied to the data in memory (after querying the dataset) or passed onto the dataset itself and have the dataset use them to query more specifically the datasource. The latter in turn can make best use of whatever features are supported in the datasource (indexes, partitions, etc) and improve efficiency of the query &amp; reduce costs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*_Vj_zZaHsxx81swVETGA0g.png" /><figcaption>Dashboard to dataset parameter mapping</figcaption></figure><h4>How can I publish a dashboard for other users?</h4><p>There are several ways:<br>- If you are working in a QS team (a group of users within QS), you can simply share the dashboard and have others view it through an invitation.<br>- You can schedule an email to be sent with a PDF copy of the dashboard.<br>- You can create an embedding url, which can be run in two different ways:<br>1) as an anonymous user (see <a href="https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GenerateEmbedUrlForAnonymousUser.html">GenerateEmbedUrlForAnonymousUser</a> api)<br>2) within a given user context (see<a href="https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GetDashboardEmbedUrl.html"> getDashboardEmbedUrl</a> api)<br>Each Api call should be used within it’s corresponding pricing model defined which are described in the next section. For the anonymous user one, the url can be used for 5 minutes, whereas for the other one the url can be used one time only. These API calls can only be used from the command line or from a server in AWS, but not directly from a web browser’s javascript. A common thing to do is to encapsulate these calls in a lambda that can be called via http by a browser and obtain a url that would be embedded in an IFrame. You can also <a href="https://www.npmjs.com/package/amazon-quicksight-embedding-sdk">use the official web embedding library</a> that will allow you to display this url on any html element, but you will have to obtain a url yourself before calling this library.</p><h4>What are the pricing models?</h4><p>Most AWS services are charged either variably by time and volume or as a fixed cost; or a combination of both. QS is different, it has two pricing models:<br>1) per user and <br>2) capacity planning.</p><p>With the per user option you pay a fixed cost per user type, for every user that at least logged in once in a month (or for a service that ran under the context of these users e.g. a lambda). There are basically two types of users a) readers and b) authors. Optionally a user can be a PRO user, which are allowed to use Q (AI capabilities) and are comparatively expensive to the standard users. Readers are much cheaper than authors, no matter how many datasources, datasets, analysis or dashboards they consume. <strong>This is a good pricing model for small development teams and a few users for reading embedded dashboards.</strong></p><p>With capacity planning you pay a fixed cost that will allow a number of reader sessions per month plus an extra cost for each session above the limit. A session is considered to be 30 minutes of interactions between the user and embedded dashboards. However, you will still pay for individual users logging into Quicksight and designing dashboards, <strong>but it’s more cost effective for displaying dashboards in the context of Reader users.</strong></p><p>⚠️AWS offers discounts for annual committments aka subscriptions, basically much cheaper user rates if you pay ahead of time in bulk. You can see more of that <a href="https://docs.aws.amazon.com/quicksight/latest/user/manage-qs-subscriptions.html">here.</a></p><p>In short: if you have many reader users that need to be authenticated and security verified when viewing a dashboard (e.g. a multitenant app), you should go to capacity planning, otherwise you may stick with a per user pricing model and use one or a few reader users only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*K_hzWuHxOlOXgesBquUnMg.png" /><figcaption>The management page with procing options</figcaption></figure><h4>How expensive can it become?</h4><p>For a scenario where you have one default admin user which is an author by default too, plus one reader user to generate a dashboard URL to be embedded, you can pay as little as 1.1 us$ per day for the us-east-1 region. If you make this Reader user a PRO (Q) user, then you would be paying around 8 us$ per day which is $250 per month. So unless you have the need to run with many users, it can become expensive for small teams. Another cost comes with the ability to generate “pixel perfect reports”, which are paged/tabular reports. Activating this feature when you setup the account, will cost you 500 us$ per month. Optionally you can use the in-memory SPICE database and make your queries use it for faster access. However be aware that you get only 10 gigs for free and the data gets updated at intervals, so extra query costs should apply. Every extra Gb in Spice is not expensive, but it all adds up. Obtaining a url for embedding a dashboard can become the most important factor when it comes to managing costs, see sections below for more details on the subject.</p><h4>How complex is the setup?</h4><p>The setup process is easy, but have in mind the following:</p><ul><li>You can have IAM users or Identity center users, or quick sight users (independent users) that can login to QS. This is a decision you will need to make when you create the QS account. Changing it later, will need you to delete and re-create the account.</li><li>The QS account is just another website independent of the AWS console, meaning you can reach it from the console for IAM/Identity center users but for QS users you need to navigate directly to it.</li><li>If you don’t know the data sources you are going to use in advance, you will need to access the QS Management console after creating these resources and grant permissions so that the QS account can access them.</li></ul><h4><strong>How do I obtain a url for embedding dashboards on web pages?</strong></h4><p>There are several API calls to get a url for a dashboard. The confusing part is which one to choose for which pricing model plus the inconvenient fact that AWS revamped most of these APIs, so most examples shown on AWS are for the older APIs or deprecated programming frameworks like node js 16.</p><p>If you are running in the per user pricing model you will need at least one Reader user to run the API under its user-context. For this, use the getDashboardEmbedUrl API call to obtain a url under the context of a QS user. However if you want to obtain a url anonymously, use GenerateEmbedUrlForAnonymousUser instead, but this one only works in capacity planning mode.</p><p>So, in short if you need to show dashboards under the context of many Reader users and enforce security, capacity planning might be cheaper than the per user pricing model. However, if you can afford to obtain a url under the context of the same Reader user all the time, the per user pricing model should be cheaper than obtaining a url anonymously in capacity planning. It’s a tradeoff between fine grained security &amp; complexity &amp; higher costs vs. coarse security &amp; simplicity &amp; lower costs.</p><h4>What other gotchas should I be aware of?</h4><ul><li>When you first create your account you get 30 days free of charge, infortunatedly you can’t see how much money you saved during that period, so forecasting your future costs is tricky if you are new to QS cost intricasies. Make sure then you start checking costs inmediately after that free period and adjust accordingly, ideally plan ahead of time by understanding the pricing models as good as possible.</li><li>If you need to embed a url on your localhost computer, make sure you enable this localhost domain on the allowed domains of the QS management pages, or specify it in the allowed domains parameters in the API calls.</li><li>Dashboards can make use of parameters, hidden or shown as filters on the dashboard itself. If you want to drive the values of these parameters on an obtained url, pass the parameters as querystring parameters like so ?#Param1=value&amp;#Param2=value. By doing this, you can have the filters driven by the webpage hosting the embedded dashboard.</li><li>Be aware there is no GIT integration or any other tool for version control within the QS design pages, only datasets have something to go back to previous versions, but the rest of the objects don’t. That’s a missing feature.</li><li>There is no feature to export a whole dashboard and dependent objects and import them back again from the UI. That’s something that makes it hard to re-create objects between environments and accounts. <br>However the AWS Command line tool :<em><br>aws quicksight start-asset-bundle-export-job --aws-account-id nnnnn<br>--asset-bundle-export-job-id JJJJJ<br>--resource-arns arn:aws:quicksight:us-east-1:nnnn:dashboard/xxxxx <br>--include-all-dependencies --export-format CLOUDFORMATION_JSON<br></em>can be used to export a full dashboard and it’s dependencies. To import it back again you can use the counterpart comand s<em>tart-asset-bundle-import-job. <br></em>I haven’t used the import command to restore QS objects from the export command’s output, so I can’t provide any comments on it, I only used the export command to generate a CloudFormation yaml template and be able to create objects from a cloud formation stack. What I can comment on, is the lack of auto-generating Ids on the QS objects in Cloudformation, so you are forced to use constant Ids or generate your own with parameters in Cloudformation. Also, the objects in QS are quite complex and large, so tweaking them for Cloudformation in yaml/json can be a lengthy and a very involved process.</li><li>If you want to have two completely different and isolated compartaments, QS supports namespaces. You need to create and delete them through the command line. Once you create a secondary namespace, it is like having a 2nd QS account completely isolated from the first one — including users, so be aware of the extra costs. This can help you for development and staging purposes unless you have another AWS account.</li><li>Something we faced early on is the lack of CSS customization on the dashboards. Clearly nobody at the product team wants to allow customers to meddle with the visual’s styling. Still, customizing the look and feel of a dashboard to match its hosting page would be useful.</li><li>Dashboards support some localization by passing a locale parameter to the embeeded url, but you don’t have the ability to write translations for variable names, dimensions etc. Around 15 languages are supported as locales, so the whole experience is incomplete at best.</li><li>AWS keeps a <a href="https://community.amazonquicksight.com/">community site</a> for support questions answered by experts, and many features got requested via this place. That’s good, the product keeps evolving an getting better.</li><li>For cost allocation control you can tag standard (no PRO) users and watch costs in the regular billing &amp; cost management pages. Tagging other objects is possible but not known to produce any useful data.</li></ul><p>I think that covered it all. Thank you for reading. Leave your comments if you think I could expand on a topic.</p><p>Boris J.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13abe646b5dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing a custom message retry mechanism on any queue with scheduled messages]]></title>
            <link>https://medium.com/@bajani2007/implementing-a-custom-message-retry-mechanism-on-any-queue-with-scheduled-messages-6b8340d440a9?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b8340d440a9</guid>
            <category><![CDATA[queue]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[resiliency]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 14:42:46 GMT</pubDate>
            <atom:updated>2024-11-26T23:26:41.714Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is something a few colleagues asked me to write about some time ago. I did the proposed implenentation originally with Azure Service Bus (ASB), but it should be doable on any other queue products available in the market.</p><h4><strong>Why implementing your own retry mechanism?</strong></h4><p>All queue products, implement some retry logic when it comes to making sure a message reached destination, e.g.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*rbHva60Ze07xLOwJ5GW9Ag.png" /></figure><p>Below, 4 popular queue products and how they implement retry logic:</p><ul><li><strong>Azure Service Bus (ASB)</strong>: by default after 10 retries in a row a message is sent to the DLQ. You can define the amount of retries with the property but not the waitime in between. There is a ServiceBusRetryOptions class in the SDK but it does not apply to message delivery *1📝.</li><li><strong>AWS SQS:</strong> Retries are based on the message visibility time-out, the retention period and the maxReceivedCount properties. If the queue as no configured DLQ, the message will be retried after the visibility period expired for as long as the message doesn’t expire within the retention period on the queue. If you are using a DLQ, you can configure the maxReceivedcount property before sending it to DLQ.</li><li><strong>Rabbit MQ:</strong> the latest versions introduced new quorum queues that allow header values “x-delivery-count” on every retried message. The amount of retries can be defined with the “delivery-limit” policy.<em> </em>In short Rabbit MQ has a method of retrying failed messages for a certain amount of retry attempts. I haven’t seen any configuration for retry interval in between failed messages.</li><li><strong>SAP’s Event Mesh:</strong> I had the opportunity of evaluating it recently with Webhooks delivery and saw it implements a staggered approach of retries where messages failed retried every 15 minutes for 12 hours, then every 30 minutes for the next 12 hours, every hour for the next 12 hours and finally once day up until the 28th day. Eventually messages can go to a DLQ if configured to do so. It does also support AQMP and MQTT but had no opportunity of working with them.</li></ul><p>*1📝If you look at the <a href="https://learn.microsoft.com/en-us/azure/architecture/best-practices/retry-service-specific#retry-mechanism-7">documentation for ServiceBusRetryOptions</a>, it looks as if these options do control message delivery, whereas what they really do is how the SDK library delivers a message to ASB. In other words, set these options to different values and check how often a message was processed by your application on a failure, no matter what you configure, your application will always receive 10 messages in a row. <a href="https://stackoverflow.com/questions/65945497/azure-service-bus-retry-options-not-working">The issue is documented here.</a></p><p>Similarly MS launched some time ago “Retry Policies” for Azure functions, <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-error-pages?tabs=fixed-delay%2Cisolated-process%2Cnode-v4%2Cpython-v2&amp;pivots=programming-language-csharp#retry-policies">see here</a>, however they do not support ASB, only at the binding level which is the client side (application against ASB), not message processing.</p><p>Back to the point, in the products mentioned above, there has been a clear intent of writing an “out of the box retry logic”, but none offer full control over the attempts to deliver a message, let alone they could be even more harmful than helpful. For example if retries happen inmediately after each failed attempt (give it or take some minor wait time for visibility expiration) and when the maximum attempts have been reached, if configured to do so, the message is sent to the DLQ. If these would be transient faults, like communications errors that would last for a few milliseconds, then retrying in a row could make sense but if the errors stem from application issues (server overloads, cold-starts, internal errors, etc). you wouldn’t want to execute every attempt one after another. More likely, you would look for ways of waiting in between every attempt, giving a chance for the issue to resolve itself.</p><p>So, in conclusion: it would be nice if these products could have some plugins developed to extend delivery logic and with it control retry attempts better; but until then if you want to gain control over retry logic, the only way is to write your own.</p><h4>How can we control retries from the application ?</h4><p>We know then that some products embed retry logic based on a retry counter stored with the message, but we don’t want to use any of this embeded logic because we cannot control it. Shouldn’t we be able to create our own? Let´s see, we just need a placeholder for a counter to tell how many times a message has been already delivered to the application. ASB messages have properties, SQS messages have attributes, Rabbitt MQ has custom headers, so yes we can store “extra” data with the message besides the payload. In the case of SAP’s Event Mesh, it doesn’t support extending the message with attributes, however the workaround would be to embed the message within another json structure that can hold the attempt number. Of course not every running application could be modified to do this, but if you are starting something new, you should be able to define the message structure to whatever you like.</p><p>Ok, we can embed the attempt number in the message, but what about making a queue, process a message with a given wait time between attempts? There are several ways of doing this:</p><ol><li>Storing a message in different queues, that have a different execution rates. Think of a queue where messages are processed inmediately, another one every 10 minutes, another one every hour and so on.</li><li>Scheduling a task to be executed in the near future, making the task post a new message to the queue.</li><li>Schedule a message <strong>through the queue itself</strong>.</li></ol><p>In terms of complexity, solution #1 is the most complex because it should have some logic that stores messages in different queues and schedules an application to go and fetch a message at intervals. However, in AWS you can create <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-delay-queues.html">delay queues</a> that can be configured to send a message at a given interval after the message was first posted. But again, this is a per queue configuration, so you will end up creating too many queues for too many cases.</p><p>Solution #2 should be the most product / platform agnostic way of scheduling a message. This could be accomplished with any CRON scheduler on any cloud platform or even on premise.</p><p>Solution #3, should be simplest of them all. In Azure Service bus you can schedule a message to become visible in the future with the SendEnqueueTimeUtc property (<a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/message-sequencing#scheduled-messages">see here</a>), in AWS’ SQS you have <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-timers.html">message timers</a> that can accomplish the same up to a maximum of 15 minutes. Rabbit MQ <a href="https://www.rabbitmq.com/blog/2015/04/16/scheduling-messages-with-rabbitmq">has a plugin for something similar here.</a> SAP’s Event Mesh doesn’t support scheduling messages *2 📝.</p><p>So overall 3 out of 4 products, do support scheduling messages. If your chosen product doesn’t, then the simplest way of doing is option #2.</p><p>Now the only thing we need is a receive handler in our code, that: <br>- reads a message<br>- if the message contains an attempt counter beyond the maximum allowed, move the message to the DLQ or simply raise an error.<br>- do whatever logic is associated to processing the message<br>- if the above fails, instead of raising an error back to the queue, post the same message again with an incremented attempt counter but schedule it for some time in the future.<br>- finally, whether the previous failed or not, always confirm the original message as processed.</p><p>Graphically we could see it like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*aScGD0anMcE4eK6GV8-SPg.png" /></figure><p>Based on the above you could improve it in many ways, like immediately raising an error when reaching the max attempt, or embed the max allowed value as another extra item with the message, or even embed what kind of algorithm should be used to calculate the next attempt schedule. There are no limits to what can be done.</p><p>But not all that glitters is gold. One drawback of this approach is that scheduled messages (in whatever way you chose) are not visible in the queue. This might arise as a challenge if you need to purge a queue or if you need to make sure there are no pending messages. ASB has added a way of showing “Scheduled Messages” in their Azure management pages, but I haven’t seen the equivalent on SQS yet. Additionally, you must be VERY careful to avoid endless loops, e.g. you must make sure a message is not retried forever. For this you could add your own message expiration as another custom property/attribute and stop processing thereafter. Finally, for tracking and debugging purposes, you must understand that a retried message will have some sort of different message ID than the original failed message. So if you want to count how many different messages an application processed, you will have to use a different key to tell.</p><p>*2 📝While writing this article I found <a href="https://community.sap.com/t5/technology-blogs-by-sap/cloud-integration-connecting-to-messaging-systems-using-the-amqp-adapter/ba-p/13419906">this SAP’s page</a> that explains how SAP has a connector for AQMP/JMS compatible queue products and provides guidance on how to implement retries based on using multiples queues (e.g solution #2) and the JMSRedelivered/JMSXDeliveryCount message properties. I can’t say if Event Mesh provides them when connecting through AMQP, but other products mentioned here are AMQP compatible too, so the article might apply in order to connect SAP applications to these other queue products.</p><p>That’s all folks. Hope you liked reading this one. <br>Boris J.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b8340d440a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A simple way of implementing semaphores and database locks in Mendix with horizontal scaling]]></title>
            <link>https://medium.com/@bajani2007/a-simple-way-of-implementing-semaphores-and-database-locks-in-mendix-with-horizontal-scaling-cda659b14405?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/cda659b14405</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[low-code]]></category>
            <category><![CDATA[database-development]]></category>
            <category><![CDATA[distributed-system-design]]></category>
            <category><![CDATA[mendix]]></category>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Wed, 16 Oct 2024 14:31:40 GMT</pubDate>
            <atom:updated>2024-11-16T23:24:18.524Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<p>I started working with Mendix around 2023, coming from regular Software development and I must admit it’s simple and powerful. However low level semaphore operations like c# locks or java synchronized statements, are not part of the standard tool-set in a microflow. Of course, you could write a java action for this, but it would lack the ability of locking a resource across many Mendix server instances (horizontal scaling); it would only be capable of locking something in memory on that server running that java action. Thinking out of the box then, we could do something such as a distributed lock with Redis hosted on a cloud provider or any other fancy solution, but for most low-code projects, a solution to such a requirement, would need to remain <strong>“cost-effective, simple and elegant”</strong>. So adding more external complexity is not always an option.</p><p>Forward thinking then, the only resource that remains globally available to many Mendix server instances is the database, but what is available on a database that could be leveraged as a semaphore? Well, all database engines do lock a record for updates <strong>📝*1</strong>, meaning that your user/database connection is the owner of that record for modification purposes and only you (your database connection) can modify or read the record with its current values after modification. This doesn’t mean that other database connections cannot read the old values of the record, they actually can. This is accomplished by the default isolation level <strong>READ COMMITTED.</strong> A database isolation level is nothing more than a set of rules that define, what can be read at what time when transactions run. Read Commited means: anyone can read anything that was previously committed in a transacion, but no one should be able to read something that hasn’t been committed in a transaction yet.</p><blockquote><strong><em>📝️*1</em> </strong>= For the sake of accuracy, any RDBMS does implement some sort of “lock escalation” for any operation involving a change of data. This does imply that, any SQL DML statement will try to lock a fine grained resource first but if not convenient at that time, it will lock something larger but less demanding when handled as a lock. So any SQL Update/Delete/Insert statement, could lock a row, a set of rows, a file page/block, a table and even the database, depending on what is cheaper for the RDBMS. Cheaper here means: consume less resources in the system or simply perform faster. A typical case of this is when you are about to update many rows, if the RDBMS can tell that the rows to be updated represent a large chunk of the table it would perhaps be cheaper to lock the whole table than every row individually — all depending on the amount of rows involved and system resources available.</blockquote><p>Following the previous thoughts then, we should be able to run an <em>update object activity with commit </em><strong><em>️</em>📝*2 </strong>within a microflow and obtain an inmediate row lock on a database table. We know that every microflow that handles object database operations, does start a database transaction and ends the transaction during the lifetime of the microflow, so the row lock will be kept for as long as the microflow runs. That’s exactly what we need.</p><blockquote><strong><em>📝</em>*2 = </strong>The change object activity will not run the SQL update statement inmediatly unless we check-mark the “commit” option in the activity and we need this SQL update to run inmediately to ejecute the row lock.</blockquote><p>But…. what would happen if two parallel microflows read an object and increment a counter on that object’s property and change the object in the database (run the SQL update)? One microflow will run the update (change object with commit) and lock the record, the other will try to run the update and will be held back (sleeping) until the record becomes free for another update lock. In this process, both microflows should have read the object before executing the update, which will most likely yield a counter with a wrong value, namely the old value + 1 instead of old value + 2 (for two microflows). This happens because the microflows read the same object in parallel, then update it with the old value + 1. Although the updates and the code past the update does not run in parallel, the final counter value can go wrong.</p><p>A work-around to the problem above, <strong>should be to have an ad-hoc object for the lock itself, instead of trying to use the main data-object as a lock. This should guarantee that a DB lock still happens but data would not be corrupted in a race condition.</strong></p><p>E.g. something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*G3qeeIGXLWjjlS6SCHMAIw.png" /></figure><p>Where Data represents the object you want to update one-by-one and where DataLock represents the object to be truly locked by the database. You could also draw a domain model association between them, just to make the relation more explicit, but for the purpose of running this technique, you don’t really need it.</p><p>Now see that UniqueId is a primary key on both (actually it is an alternate primary key <strong>⚠*3</strong>). This is because we don’t want to repeat Data objects, nor their lock objects. So the UniqueId values must match on both tables/objects. Also, on the image above, the Datalock object should have some other fields to store an updated value, like a timestamp, a UUID, etc. since the UniqueId should never be modified.</p><blockquote><strong><em>⚠</em> </strong>*3 = Mendix does internally generate an “id” property used in the database as a true primary key. However we can define unique indices by making any property “unique” and “required” at the rules definition of an entity. So that these rules can also work as an alternate primary key to the entity.</blockquote><p>In order to have the counter updated correctly, we should then run an SQL update (change object with commit) on the Datalock object, then read the Data object, then increment its counter field and finally update the Data object. <strong>This sequence will guarantee the correct results in the counter.</strong></p><p>Graphically it would look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*x_vjMb2uKFgi_tUoDtXLkg.jpeg" /></figure><p><strong>Now there is a couple of limitations on this technique.</strong></p><p>First Limitation: the lock object must exist in the database before the locking proceeds. This means that for every Data object we must have a DataLock object already created in the database. If we were to INSERT (create object activity) a lock object, at the time that two or more microflows were trying to lock the data object, all microflows would be running an INSERT with the same UniqueId and since none already exist in the database, no lock would happen at all. Furthermore, at the end of the Microflow, all but one of these microflows, would fail with a unique key violation error, because one microflow would have been able to commit <br><strong>📝*4</strong> the SQL transaction but all other microflows would have failed trying to insert an already existing key in the table. However, once the data lock object is created and the database transaction committed, everything should run as smooth as if the lock object would had been created earlier. So, adding a lock object on the fly can be done, at the expense of having a few microflows fail until the lock object is created. Ideally if these microflows run as background tasks, that are re-triable per definition, this issue is relatively minor.</p><blockquote><strong><em>📝</em>*4 =</strong> A commit transaction in SQL must not be confused with Mendix’ commit activitiy. The latter is not a true “commit transaction” SQL statement, but rather a “save all pending changes” (e.g. run all pending SQL) for objects not saved to the database yet. This is confusing for all people who start using Mendix and have a strong SQL background, until you read the documentation and understand that database transactions are implied and that the commit activity only saves changes.</blockquote><p>A second limitation on this technique is that a DB update lock is released when a microflow ends — when a final commit transaction statement is issued on the microflow that managed to aquire the DB lock. This means that if your microflows perform lengthy operations after the change object with commit (the lock) happens, you might be holding up other microflows for much longer than needed. Optionally, the community commons module, contains a START and STOP transaction java action that you could be placed in your microflow to run a commit and begin stransaction SQL statement after you performed your data updates, but this can also break the regular transaction handling of parent and child microflows — so it’s not always suitable.</p><p>Last but not least, we must mention that Microflows do not have a database timeout. Which means, that if a row lock is active and held for a long time, other sleeping microflows will not be interrupted / rolled-back. So, extra care must be taken to avoid blocking other microflows endlessly.</p><p>If you would like to implement this technique, you don’t really need another ad-hoc table for each object class in your domain, you could simply have a generic table for all objects in your application, as long as the UniqueId is truly unique across all objects types. And if the UniqueId is not truly unique, you could store in the DataLock UniqueId field the table/class name + the Unique Id of the object you want to lock.</p><p>As a final hint, if you want to test all this out yourself, launch many microflows , e.g. a 100 microflows in the background with a task queue that runs many tasks in parallel, ideally more than the amount of CPU cores your computer has. Then use the logMessage activity to log the amount of time the change object activity for the lock took and you will see some worked around a few milliseconds and other ones way longer — the longer ones are the ones held back during a DB lock. Another way of testing it, is to use the same task queue and write a condition on your microflow to execute the DB lock or not, then check your counter final value after all tasks ran. With the DB lock the counter should always be equal to the amount of microflows tasks that ran in total, without the DB lock the final value could become less.</p><blockquote><strong><em>💡</em>Note:</strong> The technique presented in this article is nothing more than a pessimistic database lock, without using the original row that is to be locked. All because Mendix does not support anything like it out of the box. However, there are marketplace modules that can accomplish the same, for example this one: <a href="https://marketplace.mendix.com/link/component/109405">https://marketplace.mendix.com/link/component/109405</a> but this module is specific to Mendix 9 version, which is rather old in 2024. However this technique presented here, should be runnable on any Mendix version, with any RDBMS.</blockquote><p>Hope you enjoyed reading this article. Happy low-coding.</p><p>Boris J.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cda659b14405" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To be serverless or not…. Net 6 migrations Intermezzo]]></title>
            <link>https://medium.com/@bajani2007/to-be-serverless-or-not-cc3ac091740b?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc3ac091740b</guid>
            <category><![CDATA[net6]]></category>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Sun, 12 Nov 2023 21:50:03 GMT</pubDate>
            <atom:updated>2024-10-23T01:07:44.114Z</atom:updated>
            <content:encoded><![CDATA[<h3>To be serverless or not…. Net 6 migration Intermezzo</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*0jhvgv21wEndDPdVbIhVEA.png" /></figure><p>As promised on Part 1, I was planning on writing a short story of my experience migrating Azure functions to Net 6 (no AWS rant today :-)</p><p>So this is how it went…</p><p>In general the migration process was easy, we followed MS’ instructions and had no issue with them.</p><p>However two particular problems arose with the final code going to <strong>production *1:</strong></p><ul><li>Cloud_RoleName suddenly gone away for each app logging on App Insights</li><li>Cold-starts in Consumption plan became much worse than before.</li></ul><p>The Cloud_RoleName issue was not a new thing. That’s something we saw from very early stages with Azure Functions, which we fixed by setting up a custom telemetry initializer or by not promoting the startup code to implement IWebJobsStartup and use Functionstartup instead. As matter of fact MS and Visual Studio have been warning us for ages about not using IWebJobsStartup, so we had been at breach here for a while, however every time we went to use FunctionaStartup we lost the Cloud_RoleName and no comments available on the internet as to why. Plus we saw other issues on the internet related to this class, but one was enough to leave as is and never upgrade. But this time with net 6, with or without FunctionsStartup we did miss the Cloud_RoleName in the telemetry <strong>all the time</strong>.</p><p>So, in order to try to fix this issue for once and for all, instead of migrating the existing code, we started a new clean Azure Function with VS and deployed it to the cloud, this one of course with FunctionsStartup being used; and to our surprise all telemetry requests and dependencies were logged flawlessly. Hmmm… so what did we miss before then? And the answer is “traces”. Since very early on, I mean as far as 2017 we had been registering a telemetry client in our dependency injection code and guess what? It doesn’t work anymore with Net 6, or better said interferes with the regular requests and dependencies logging.</p><p>So we finally fixed the issue by instantiating a static telemetry client in a helper class, but not through dependency injection, and have all traces log through a method on this helper class. <strong>Problem solved</strong>. Now this proves how inconsistent Azure Functions releases are and what little documentation exists. This was an issue we had been living with for years, probably since Azure functions V2, being now at V4 with Net 6.</p><p>So that was the first issue, the second issue is probably even a bit shadier.</p><p>Since Net 6 was announced there was so much hype about the performance improvements, that very high expectations had been building up. So before releasing the first set of Net 6 converted Azure Functions to Prod, we did a lot of benchmarking with different workloads and in general we saw some better performance perhaps a 10 to 15% improvement at best. But very inconsistent to be honest. Now when these over-tested apps went to production, not to my surprise (if you’d been reading my earlier posts) but to everybody else’s surprise <strong>we saw more random cold-starts and a clear performance degradation during peak workloads. </strong>I tried<strong> </strong>to find<strong> </strong>any technical articles on the subject, but it seems there are very few companies daring to run production code with consumption plan and in some of the comments I read: “<em>we contacted MS about these Azure Functions in Net 6 performing worse than before, they finally fixed some and broke some others. After 3 months we finally gave up and upgraded them to premium&quot;. </em>So, I gave up too.</p><p>Last but not least, on the subject of testing mentioned in <strong>*1, </strong>I just can’t comprehend how testing teams overlook non functional requirements over and over again. It’s a Deja Vu on every project I work on.</p><p>I think this is all for this short story on Net 6 and Azure functions. Hope you had some fun reading this blog,</p><p>Boris J.</p><p><em>Legal Disclaimer: The views and opinions expressed here are those of the author only and do not necessarily reflect the views or positions of any other entity that the author has or has had any relation with.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc3ac091740b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To be serverless or not…. Part 4]]></title>
            <link>https://medium.com/@bajani2007/to-be-serverless-or-not-41a5771f8eee?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/41a5771f8eee</guid>
            <category><![CDATA[lambda-function]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[cloud-architecture]]></category>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Sun, 22 Oct 2023 11:08:59 GMT</pubDate>
            <atom:updated>2024-11-29T12:08:52.081Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<h3>To be serverless or not…. an honest and opinionated comparison of Azure Functions and AWS Lambda functions for the modern software developer — Part 4–Oct. 2023 — Fifty shades of performance.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*82a-dVa6jFnkVM2eiKnG0w.png" /></figure><p>Welcome to my 4th installment on a series of blog posts about Azure and AWS Lambda functions. If you haven’t read my earlier ones, give them a try, I believe I did a fair job at exposing lots of gotchas in both technologies and I hope to do justice on this topic too.</p><p>So, here I go…</p><p>These are the most common issues that affect serverless functions, at least in the sense of trying to keep them running at predictable performance:</p><ul><li>Cold-Starts (AWS &amp; Azure)</li><li>Difference between running one request per instance (AWS) or sharing one instance for many requests (Azure) .</li><li>Application initializations during startup that are redundant (AWS &amp; Azure)</li><li>Random hardware provided (Azure functions in consumption plan) across environments.</li></ul><p>Ok, so everything I mentioned above are probably the most well known issues, but what else can affect a function’s performance?</p><ul><li>Dependencies</li><li>Trigger paralellism</li><li>Garbage collection</li><li>Network quality</li></ul><p>Let me start with network quality by comparing Azure and AWS’ networking capabilities in a very general way:</p><ul><li>Both allow creating a private network (vNet in Azure and VPC in AWS) where resources do run under the best possible conditions (performance and security).</li><li>Both vendors cannot guarantee communications outside of their networks.</li></ul><p>On the latter it makes sense, you can’t guarantee what’s outside of your control (in all fairness the private networks aren’t even mentioned in the SLAs, but if you can see a logged network error and call support, they should listen at least :-) .</p><p>But here is a big difference with both vendors:</p><ul><li>When you start a new project in AWS, the first thing you are compelled to do is to create a VPC and connect your services to it. If by any chance you need public access to them, either you enable a public endpoint (if supported) or you route to them through an API gateway. Optionally for management or development purposes you connect to them via a VPN.</li><li>In Azure all Services are publicly available by default. You are not forced to make them private, nor connect them through a vNet.</li></ul><p>Both approaches have their pros and cons. I always loved the fact I could reach remotely (most services) in Azure with little effort. With AWS, you will need some time to get there. Another nice thing in Azure is that you can prototype things faster and when time and money allows, do all the networking part. But this Azure “convenience&quot; has a hidden downside. Besides the fact that you wouldn’t want your databases and microservices exposed unnecessarily on the internet, you are connecting all your components through a less than optimal network path. Furthermore these paths can be overloaded and are not officially guaranteed by the cloud provider (as mentioned above). Ok, public networks are not that efficient and reliable, but by how much?</p><p>In my experience in the last 7 years I found:</p><ul><li>Dns errors</li><li>Sudden disconnects across services or services against databases</li><li>Random slow responses from azure services under very little system load, causing timeouts.</li></ul><p>And all of the above heavily multiplied if high workload was applied, even with server over-provisioning and prewarmed instances.</p><p>So how hard is it to create cloud services and connect them through and to a private network?</p><p>In AWS creating a VPC is a no-brainer. What’s hard is to understand what permissions/policies that must be applied to each service in order to connect to a VPC (you must grant permissions to a service in order to have it connect to a VPC). But once you grasp the concept, it’s a cookie cutter job.</p><p>With Azure, the answer is: it depends. It varies by service and you need to plan ahead a bit, even your architecture (software and cloud) must consider it. Ok, let’s explain it: in Azure connecting services to a vNet varies by service, there are basically 3 mechanisms:</p><ul><li>vNet integration</li><li>Service endpoints</li><li>Private endpoints</li></ul><p>Without having to go into details on each of them, the fact is that the 3 features allow to expose or connect your service on a vNet and make use of the Azure network backbone instead of a public network. In short, all 3 options allow you to connect resources in the most efficient manner, but you don’t get these features by default as in AWS, nor you are forced to use them, so this is the big difference. Furthermore many services have a fine print which not everyone observes:</p><ul><li>Azure functions in Consumption Plan<strong> DO NOT SUPPORT </strong>any kind of vNet integration.</li><li>Services like Redis or Azure Service Bus do not support vNet integration, unless you are running on a Premium pricing tier.</li><li>Not all plans (hardware profiles) support vNet integration. Premium ones do by default, standard and basic only if created recently (past 2020)-</li></ul><p>And there might be more services and configurations that do not support vNets in Azure. In AWS all this cumbersome-ness doesn’t exist, at the expense of making your life harder at the beginning but getting things done right from the start.</p><p>Now, why did I mention your Architecture must consider vNet integration in Azure ? Let me give you an example. If you are thinking of creating a WebApi, you can use both functions (AWS/Azure). But if you are planning on using an Azure one, in consumption plan and your function is bound to the UI, you can have Network errors or delays at any time due to using a public network, plus have cold-starts added at any time too. <strong>So, you are seriously increasing the chances of failures for your users (see ref 1.1.1 on my earlier posts and draw conclusions :-)</strong>. However if you make your Azure functions in consumption plan, do only react to events, on a process that is not UI bound, then the chances of perceiving a failure by a user are much lower. On top of that, if the task is based on an SDK Operation with embeds retries or if the task participates in a saga that can be rolled back or re-executed after a failure, the event execution might take long but not fail. So clearly, <strong>your functions’ availability and reliability affect your Architecture and must be taken into account when designing.</strong></p><p>In AWS, connecting services through a public network can be done, but that would be rare and specific to a particular requirement, so chances of running into all these problems are much, much lower.</p><p>Ok I think I made my point clear that using public networks can be bad. Now another item on the list is dependencies. And when people hear the word “dependencies” they immediately think of microservices and reducing dependencies to other services and using event driven architectures. All valid points, but what about it’s most basic form: dependencies to resources a Microservice owns? So if a database, distributed cache or service bus runs slow, who are we going to blame? Obviously the developer must be blamed (it’s a common practice :-) … but in all seriousness what if any of the above run slow? What if using a public network to access dependencies makes them slower? The first thing we should be able to do is to use a monitoring/observability tool to pin-point these issues. I have worked for years in Azure with app insights and kusto queries and I have nothing but admiration for this tool. But honestly it falls short, not because of the tool itself but because MS did not integrate all Services to it. It works well for http requests (in and out) on a Microservice, but databases, Redis and Service Buses do not log their network requests, because many don’t use http. So, point being, you are not going to see in appinsights all problems, but only some based on http only. Azure does also log metrics for most services, which vary by service and none I remember consider network errors and client retries as a metric to be watched. For example Azure functions do log “cold-start time”, which is useful, but appservices do not, even when both can scale out similarly with cold-starts. So in my experience metrics are useful, but inconsistent at best.</p><p>As for AWS, I have used Cloudwatch now for a couple of months and I can see some points in common with app insights, but I can’t provide any serious comparison yet. Perhaps another topic for another blog. There is an AWS extension called “AWS x-ray” which makes available logging of cold-start times and dependencies. But same as with Azure appinsights, not all Services support this extension, see:</p><p><em>X-Ray tracing is currently not supported for Lambda functions with Amazon Managed Streaming for Apache Kafka (Amazon MSK), self-managed Apache Kafka, Amazon MQ with ActiveMQ and RabbitMQ, or Amazon DocumentDB event source mappings.</em></p><p>So in short: <strong>dependencies is a big deal, but not always observable and directly affected by network quality.</strong></p><p>As for garbage collection, every modern language uses it, so each language might have its own set of enhancements for server applications. Watch for recommendations on each language.</p><p>Lastly, trigger paralellism does affect performance, because the amount of events being processed by a function, will also determine how many instances of a function will be launched and thereby cold-starts triggered. Or a dependent service might get easily overloaded with too many parallel requests coming in, so even if your function can scale, your dependent service might not. So this is something to carefully plan and test. In AWS you will find that when setting up a trigger, there might be an associated parameter for how many events should be read from the source in parallel and sent to the Lambda in bulk, but this varies by trigger type and not all triggers support it, so this is something to consider when architecting an event driven solution based on Lambdas.</p><p>With Azure functions, the amount of parallel event processing is fixed or dynamically managed, but controlled from the main host.json file on each function. However this does not guarantee that at any point in time, only N events are processed in parallel by all instances of an Azure function type. The fact is that Azure functions are governed by a scaling algorithm that might choose to create more instances of the function not only based on memory and CPU but depending on the length of queues being monitored for events. As per documentation: <em>The scale controller uses heuristics for each trigger type. For example, when you’re using an Azure Queue storage trigger, it scales based on the queue length and the age of the oldest queue message.&quot;. </em>I found though, that you can have some control over this behaviour by limiting the amount of Azure function instances that can be instantiated, which AWS does not support per function but globally for all function types in the account.</p><p>So, in my final judgement I think AWS will provide a more consistent performance experience, since most of the Azure issues are directly avoided when building a VPC. However Azure is still a winner at providing a much direct and less involved setup experience for pilot or smaller projects.</p><p>Thank you for reading, hope you enjoyed this article,</p><p>Boris J.</p><p>References and other good reads:</p><ul><li><a href="https://dev.to/gkarwchan/azure-networking-recipes-connect-azure-database-and-an-azure-app-service-using-virtual-network-57l8#:~:text=If%20your%20application%20is%20connecting,to%20have%20private%20endpoint%2C%20and"><em>Azure Networking Recipes: Connect Azure Database and an Azure App Service using Virtual Network</em></a></li><li><a href="https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-name-resolution-for-vms-and-role-instances#:~:text=Not%20applicable-,Azure%2Dprovided%20name%20resolution,-Azure%20provided%20name"><em>Azure-provided name resolution</em></a></li><li><a href="https://aws.amazon.com/blogs/networking-and-content-delivery/improving-performance-on-aws-and-hybrid-networks/"><em>Improving Performance on AWS and Hybrid Networks</em></a></li><li><a href="https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-intermittent-outbound-connection-errors">Troubleshoot-intermittent-outbound-connection-errors</a> (Azure)</li></ul><p><em>Legal Disclaimer: The views and opinions expressed here are those of the author only and do not necessarily reflect the views or positions of any other entity that the author has or has had any relation with.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41a5771f8eee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To be serverless or not…. Part 3]]></title>
            <link>https://medium.com/@bajani2007/to-be-serverless-or-not-c30412026eb4?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/c30412026eb4</guid>
            <category><![CDATA[lambda-function]]></category>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 19:43:54 GMT</pubDate>
            <atom:updated>2024-10-23T01:08:48.950Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<h3>To be serverless or not…. an honest and opinionated comparison of Azure Functions and AWS Lambda functions for the modern software developer — Part 3–Oct. 2023 — Isn’t that DevOps’ job?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*a2dI8-nS9wO_hAPeecRdjw.png" /></figure><p>Hi all, thank you for getting this far. If you managed to get to this page, it probably means you already read part 1 and 2 of my series and kinda understand my position about Serverless technologies and how they fit in today’s modern IT landscape. In this article I am going to present my views and some experiencies of how well or not DevOps is getting integrated to the SDLC on cloud applications. Yes, “cloud applications” broadly, not Azure/AWS Lambdas specifically, but my experience with the subject started with Serverless functions, so that’s where I am coming from.</p><p>On my 2nd Cloud project, which lasted many years, we started small, almost like in “start-up mode” and had only one DevOps guy in India.<br>We were a distributed team around the globe, but mostly in the Americas, so working with a guy in India to get something done swiftly wasn’t the easiest, but it worked. The project was a typical microservices setting, a UI, an API Gateway and a bunch of back-end microservices. Nothing out of the ordinary for today’s standards.</p><p>But a problem that started to be perceived from the begining was that getting an environment setup correctly, was very hard if you couldn’t work side by side with a DevOps guy who had administrative permissions to manage all these resources. So later on, CI/CD was integrated, but still things like Database changes, Service Bus setups, Storage and other dependent resources was error prone, simply because our DevOps guy didn’t work side by side with us and we were timezones apart.</p><p>So management, took the decision to “minimize Devops” contact and have the applications “do all the setup-work”. That meant, write your apps in such a way that when they start, they would have to:</p><ul><li>Check if a database exists, if not create it.</li><li>Check if all tables / collection in the database exist, if not create it.</li><li>Check if all indices in all tables / collections exist, if not create them/update them</li><li>Check if any pending DB migration exists, if so, run it.</li><li>Check if a Service bus topic exists, if not create it.</li><li>Check if a Service bus subscription exists, if not create it</li><li>And whatever other pending cloud resource was missing, take charge and get it done!</li></ul><p>Now, you may disagree with this approach for many reasons. First and foremorest: Isn’t this Devops Job? Secondly: Couldn’t this be automated with some scripts associated to the app so that we can manually run all this whenever needed? … and the list goes on.</p><p>All valid questions, but you heard the order, it has to be done.</p><p>I worked at the meantime as a part-time free-lance developer also with Cloud applications and I’ve seen other companies taking the same approach. But some others left the responsability to DevOps, so there was a great divide here.</p><p>I found that the companies who put the responsability on DevOps, had in-house DevOps, close or part of the agile team, perhaps sometimes a shared resource across many teams, but people who understood the applications and had been involved with the project from the very beginning.</p><p>The companies who did not put the responsability on DevOps were usually larger international corporations who used to outsource DevOps to a more cost-effective place around the world — and let’s be honest, with a high turnover of DevOps engineers who barely kept track of what the application and company did.</p><p>Ok, we have clearly two approaches to the same thing. Both work, both have their pros and cons. But, what are the changes in the applications with each approach? (besides the obvious fact of having to add startup code :-)</p><p>The first thing that changes is performance. On the “No DevOps” approach, every time a new server instance starts, you may lose “seconds” running all checks. So imagine your function is a WebAPI endpoint, which in average takes 100 ms to run, which could be affected with cold-starts adding a delay of seconds to it, which on top of that we just added a few seconds more for checking if dependent resources exist. Adding insult to injury, unless running on a free period of your functions, you are actually paying more money for the extra time consumed (see Part 2 of these series if you are not following). <strong>If you ask me, this doesn’t add up.</strong></p><p>Now on the “DevOps” approach, your apps must assume Databases, Collections/Tables/Indices, Service Bus topics, Subscriptions, etc. are all created and when your endpoint runs, they go straight connecting and performing an operation on these resources. So your endpoint remains at that, in the average of 100 ms as we mentioned before.</p><p>Ok, clearly Devops wins, but management still doesn’t buy it. So, what can be done to speed up the setup process?</p><p>At the time we noticed of all this, we were running:<br>- Azure Functions in Consumption plan<br>- Cosmos, Mongo and SQL Server Databases<br>- Azure Service Bus</p><p>So digging deeper on the documentation, MS’ recommends to avoid completely Metadadata operations for Cosmos on Production environments because they are slow and aren’t covered by the main product SLA *1 (Medata operations are DDL operations from the SQL world, and in plain english: all operations that create or update database objects and not the data). Awesome, we are now being asked to check for objects (Metadata operations), quite frequently and the vendor says this is a bad idea. Clearly MS is aligned with the DevOps approach, so we won’t get any support from them :-).</p><p><strong>*1 = </strong>For all those Cosmos aware Developers, even if you increase RUs, at the time there wasn’t even autoscale, metadata operations won’t run any better.</p><p>Other issues we found, were that in all MS’ SDKs for their Azure services there are embedded retry mechanisms. This means, that you as a developer, tester, or even a user, you could perceive that a given operation from a service to an Azure resource can run slow and if so, it could simply mean “the network is slow or faulty, the resource on itself is slow, or even your service is slow”, but you are not going to be told about it, you are just going to perceive a slow operation, that’s life. Now, all these retries are a double edged sword, because as nice as it sounds to have an SDK that retries for you transparently, it also means you have an underlying issue you are not aware of and might never get fixed.</p><p>So in short, having all the setup code embedded on startup can affect the application performance because:</p><ul><li>You are adding extra time to the startup of a service, that already could be affected by a cold-start</li><li>You are running Metadata operations on services that you shouldn’t and are slow or even faulty</li><li>And on top of that, all SDK operations are subject to be retried, so the more you do of them, if the resource or network is running slow, you are going to be adding more time to the startup process.</li></ul><p><em>Side note: before getting complains that this article has become too Azure-ish, here: </em><a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff"><em>https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff</em></a><em> this is the same thing for DynamoDb. I rest my case.</em></p><p>All this, for the sake of reducing contact with Devops, ok but some sort of improvement should be possible. In the end, if we had DevOps doing the same steps in a powershell script before a new version of an app is deployed, then why can’t we have apps just execute this code only once? only when the a new version of an app gets deployed? Is that possible?</p><p>Actually it can be done, this was the solution:</p><ul><li>Azure Functions are deployed to Blob Storage. So intances, of the same application are loaded from the same File System, same files, same folders.</li><li>If the File System is shared and is writeable, can we put a flag in the File System to let the app know the application setup process did run? Yes. That’s what we did.</li><li>How? A simple text file, containing simple timestamp with Net’s Running Assembly Compile Date was to be written after the setup process completed.</li><li>Then on the next server instance starting up, the file should be read, inspected and if the same running Assembly Compile Date found assume the startup process completed. In case the file cannot be read or found, simply assume the setup process did never run.</li><li>The penalty for all this 50 to 150ms on every new instance. Still better than losing seconds every time.</li></ul><p>And voila! We improved performance, the boss is happy and life is good.</p><p>Other options to do the same, could be to not embed a timestamp in the text file, but simply assume if the file is present then the startup process ran succesfully. But if you choose this path, make sure that on every deployment the text file is deleted. In ADO, this was a checkbox saying “delete all files not contained in the package”.</p><p>As for AWS, I haven’t had the need to do such a thing yet, but by investigating a bit the “/tmp folder” is shared across functions calls of the same Lambda. So the same effect should be achievable, you can read about it here:<br><a href="https://docs.aws.amazon.com/lambda/latest/operatorguide/execution-environment.html">https://docs.aws.amazon.com/lambda/latest/operatorguide/execution-environment.html</a><br>see “<em>There is also a local file system available at /tmp for all Lambda functions. This is local to each function but shared across invocations within the same execution environment. If your function must access large libraries or files, these can be downloaded here first and then used by all subsequent invocations”</em></p><p>Ok I think this is it for Part 3, I hope you found this article interesting,<br>thank you for reading.<br>Boris J.</p><p>New: part 4 published <a href="https://medium.com/@bajani2007/to-be-serverless-or-not-41a5771f8eee">here</a></p><p><em>Legal Disclaimer: The views and opinions expressed here are those of the author only and do not necessarily reflect the views or positions of any other entity that the author has or has had any relation with.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c30412026eb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To be serverless or not…. Part 2]]></title>
            <link>https://medium.com/@bajani2007/to-be-serverless-or-not-d546d7343315?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/d546d7343315</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda-functions]]></category>
            <category><![CDATA[azure-functions]]></category>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Sun, 15 Oct 2023 00:34:10 GMT</pubDate>
            <atom:updated>2024-10-23T01:01:19.588Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<h3>To be serverless or not…. an honest and opinionated comparison of Azure Functions and AWS Lambda functions for the modern software developer — Part 2 –Oct. 2023 — Costs and Productivity</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*DtpZOgI9vVNSnG_TRgKC2A.png" /></figure><p>This is my 2nd installment on a series of blog posts, about Azure Functions and AWS Lambdas. I thought of jumping straight into technical problems and how to solve them, when I realized I would never be able to explain them without context. So this blog post will be mostly about debunking some myths around Costs and Productivity always focusing on Azure / AWS Lambda functions.</p><p>So here I go…</p><h4>Part 2: Costs and Productivity</h4><p>Let me start, by enumerating the benefits of serverless computing. I will just google them: Faster time to Market, Focus on Apps not Ops, Scale Rapidly, Pay per use, Agility and Innovation, Polyglot Applications and Seamless App Deployment. Now, if I had to summarize all of the above in one sentence I would go with “lower costs and higher productivity”.</p><p>In my previous blog post, I explained that Azure functions come in 3 flavours, each escalating in cost and setup complexity as you demand more of them, whereas AWS Lambdas are more linear in that sense and provide a more stable throughput from the start. So, if I had to judge how both technologies can be accomodated for higher demands, I prefer AWS since I don’t need to upgrade my Lambdas to a different variant.</p><p>In terms of operation costs (e.g. pay per use), both technologies can run into Serverless billing anti-patterns. Imagine you would have a Serverless App calling other Serverless Apps through HTTP. For example App1 calls and waits for App2 and App2 calls and waits for App3. What would happen if App3 takes too long to respond? App1 and App2 would be waiting for a long time, not producing anything, but you are going to be billed for all of them, when in reality only App3 did someting useful. This is clearly an anti-pattern that might not ever get noticed with fixed cost servers, not because you are not paying anything for these fixed cost resources, but because a WebAPI on a fixed cost server that has to wait for an I/O response, can switch context and do something else in the meantime, whereas with Azure/AWS Functions <strong>you pay for the wait time of your function on each call.</strong> Ok I know what you are thinking here: if the software architecture doesn’t conform to serverless standards, then this is not a serverless problem and secondly, in that App1,2,3 example you may still pay less than on a fixed cost server setting. True, but you are still paying more than you should and possibly, you could be outrunning your budget if you don’t architect your apps right.</p><p>Eventually, as I mentioned in Part 1, your applications will receive more demand and you might want to upgrade them to keep more warm servers (either as Premium in Azure or Concurrency settings in AWS Lamdas), all in favor or minimizing cold-starts and providing a more stable and predictable throughput. And here is where your costs <strong>will slowly shift from variable to fixed</strong>. And if not completely fixed, at least not completely proportional to the “pay per use” premise.</p><p>So in short, <strong>your software architecture must be VERY WELL aligned with your Cloud architecture</strong>, having “costs” as a main constraint from early stages of your project. You should be able to forecast demand and be able to adapt to it quickly by reconfiguring your serverless functions.</p><p>And this opens another slew of questions:</p><ul><li>In a typical hectic Agile Software Development environment with many teams, many microservices, tight schedules and rushing into delivering something that complies with an AC every day…. how many of these teams do actually work with a Software/Cloud architect or guild? How many do even receive non functional requirements about software/cloud architecture? (If you are not familiar with the term guild, this article is great: <a href="https://medium.com/@dave.b.kaplan/agile-guilds-the-yodle-way-47dc00f6cd3a">https://medium.com/@dave.b.kaplan/agile-guilds-the-yodle-way-47dc00f6cd3a</a>)</li><li>And how many of these teams have been given access to a Cost Management Console in the Cloud or have a way of learning what works and what doesn’t in the Cloud? (not to mention official training courses)<br><em>Side-note: As I write this, I just saw this article: </em><a href="https://awstip.com/run-aws-on-your-laptop-introduction-to-localstack-7269c19dedae"><em>https://awstip.com/run-aws-on-your-laptop-introduction-to-localstack-7269c19dedae</em></a><em> — I can’t wait to test it myself, sounds awesome!</em></li><li>Last but not least, how can any of these teams project what costs would happen in the future, or how can they even simulate the load to project those costs?</li></ul><p>For example, I’ve read stories where some development team started working on a cloud environment and learnt that a given service they subscribed to was too expensive, not because they watched an alarm coming from the cloud, but because they received an alarm from their accounting department when they received the bill (although I doubt this ever happened with serverless functions, it’s still a good story).</p><p>In my mind, all this happens because there<strong> is a big disconnect</strong> between development teams, cost projections, software/cloud architects, management and stakeholder expectations. And this is where Serverless fits in, at least from a marketing pitch perspective (it’s an easy sell).</p><p>So what about higher productivity? Both AWS and Azure Functions provide a very simplistic programming model to react to “triggers” (aka events) coming from different sources, bind this input to a method, process something on the method and optionally bind the output to another destination.</p><p>Triggers for both Azure and AWS do encompass Service Buses, Databases, FileStorage, Http requests, Caches, you name it. Pretty much every available service can be bound to a function as a trigger.</p><p>Both have the option to develop on the Cloud portal, binding triggers and output; or use regular IDEs to develop on your computer with many programming languages. However, each has a different use-case:</p><ul><li>Developing on the cloud: Both AWS and Azure support writing code in the Cloud. In Azure from 8 officially supported languages only 3 are available on the Cloud, whereas in AWS with 8 supported languages also, only 2, Python and Node Js, are supported. Another issue is that whatever you develop here, this is not integrated to a code repository, you can of course download the files and archive them somewhere, but the main use case here is to provide a quick way of creating automation tasks instead than applications controlled by SDLC.</li><li>Developing on an IDE : these are simply known as compiled functions and are the best option to integrate with CI/CD pipelines and a SDLC. The most common IDEs today are Visual Studio, Visual Studio Code with plugins/extensions and Intellij IDEA also with plugins/extensions. I do want to mention Eclipse which I consider the most renowned IDE for Java of all times, but I recently installed the AWS Toolkit for Eclipse to finally find out it was deprecated and AWS recommends anything but Eclipse. See <a href="https://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/welcome.html">https://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/welcome.html</a></li></ul><p>Can I run the Function code on my computer or do I have deploy them to the cloud?</p><ul><li>MS provides the “Azure Functions Core tools” that provide an emulator to run an Azure Function in your computer. With Visual Studio this comes out of the box. With VS Code you need to install it yourself. See <a href="https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-node?pivots=nodejs-model-v4#install-or-update-core-tools">https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-node?pivots=nodejs-model-v4#install-or-update-core-tools</a></li><li>AWS provides the SAM (Serverless Application Model) which is a set of tools that contains also an emulator. You can see it here: <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/using-sam-cli-local-start-lambda.html">https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/using-sam-cli-local-start-lambda.html</a><br><em>Side note: I haven’t tried SAM yet, so I can’t provide a review, I’ve tried it with Java 17 and Vs Code and couldn’t get it to work.</em></li><li><strong>P</strong> fast. Cons: no hit hub integration, buggy, hangs randomly. Only 2 templates available: node js and python. Used python didn’t work. Failed to consume environment variables. Tested it with 2 developers sharing the environment and annoying popups of changed settings showed every 5 minutes. No support for layers. could reuse an existing lambdas code, had to create a new one. <strong>Overall a bad experience.</strong></li></ul><p>Another difference between Azure and AWS in their programming model, is that with Azure Functions methods have a different signature according to the trigger type, so for example:</p><p>For an http trigger:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*5L4eia8ieBegsqhmHhtAbA.png" /></figure><p>For a timer trigger:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*nrO46d0I0OPCv2EvaQ8www.png" /></figure><p>For Blob Storage trigger:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*ym_hd4eCW86K2Yy-Zps-WQ.png" /></figure><p>and so on, whereas in AWS there is a generic “handler method” that either receives a Json String, binary stream, a typed Object, or different combinations thereof depending on the runtime.<br>For example:</p><p>Java 17 handler receiving a parsed Map:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*poS6BxDKI84mbE6kqvFIiA.png" /></figure><p>Java 17 receiving streams:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*KZfKl9-inN4PuIZR4RWVwg.png" /></figure><p>.Net Core receiving a typed class defined in an AWS Library:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*I_arsyP9zHJFNu0CxzV2ig.png" /></figure><p>A Node Js example, receiving an event object:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*32mKRkDVGbaYu2EQf26fPA.png" /></figure><p>So both programming models have their pros and cons. Azure can be very declarative, providing a lot of help to the developer. AWS on the other hand, provides a more generic approach to handle any kind of event, in a very generic method to “catch all inputs”. Bindings in AWS, are never defined in Code, they must be specified in the Lambda Console for Triggers, so overall AWS provides way less help to the developer and too many options for all runtimes.</p><p>One limitation I perceive on both programming models, is that they are <strong>too proprietary.</strong></p><p>It would be nice if the two vendors would provide in their programming models a way of taking a WepAPI project (any language) and allow extending it to run as a Serverless function without losing it’s previous functionality, otherwise you just need to start from scratch. Specifically on AWS, you can write an ASP.Net Core WebAPI and deploy it as Lambda function, or you can write a Java Spring boot app and run it as Lambda. With the .Net case, if you enable the regular event handler method, all other regular endpoints cease working. Haven’t tried the spring boot one yet.<br>For Azure Functions, I haven’t seen anyone transforming a previous WebAPI/MVC app into an Azure Function.</p><p>An issue I found with Azure functions in consumption plan, is that the hardware you get is random. This impacts directly in the amount of cold-starts you get and can render a whole testing session useless once you deploy to production because you can get a completely different behaviour in terms of performance and stability. This, in turn, <strong>increases development costs and lowers productivity</strong>.</p><p><em>Side note: if you are interested in seeing what hardware you did get on your Azure Function, go to the kudu console and watch the environment variables. Take a look at the virtual cores. Do the same with different environments, if you are luckly you might get the same amount.</em></p><p>So, in my judgement, <strong>productivity is highly amplified using Serverless Functions</strong>, because their programming models provide so many out of the box interfaces and tools to other services, that you really can focus on application logic instead of infrastructure or technical details. However getting all your gear right and running the functions locally can be a challenge, especially on AWS. Azure functions in consumption plan, although very powerful from the programming model perspective, can be very unpredictable in terms of performance and stability.</p><p>Ok this is it for part 2. Hope you enjoyed the article, thank you for reading.<br>Boris J.</p><p>New: Part 3 is available <a href="https://medium.com/@bajani2007/to-be-serverless-or-not-c30412026eb4">here</a></p><p>References and other good stories to recommend:<br>- <a href="https://www.linkedin.com/pulse/webapi-azure-functionhttp-triggered-vs-app-service-eklavya-gupta/">https://www.linkedin.com/pulse/webapi-azure-functionhttp-triggered-vs-app-service-eklavya-gupta/</a></p><p><em>Legal Disclaimer: The views and opinions expressed here are those of the author only and do not necessarily reflect the views or positions of any other entity that the author has or has had any relation with.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d546d7343315" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To be serverless or not…. Part 1]]></title>
            <link>https://medium.com/@bajani2007/to-be-serverless-or-not-fef4590c79c3?source=rss-c23427067b22------2</link>
            <guid isPermaLink="false">https://medium.com/p/fef4590c79c3</guid>
            <category><![CDATA[aws-lambda-functions]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[azure-functions]]></category>
            <dc:creator><![CDATA[Boris Janischevsky]]></dc:creator>
            <pubDate>Fri, 13 Oct 2023 17:11:55 GMT</pubDate>
            <atom:updated>2024-11-01T10:51:15.682Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<h3>To be serverless or not…. an honest and opinionated comparison of Azure Functions and AWS Lambda functions for the modern software developer — Part 1–Oct. 2023 — Evolution and Vendor Support</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*5qbt1Wn6oEc5niYisLbHvA.png" /></figure><p>In this day and age, where we all are hit daily with buzzwords, products, advertisement and why not say it: “opinions” about almost everything I just thought I could share my own point of view and experiences with Azure Functions and AWS Lambdas. Most of the information you can find on this article are things you can read on the internet or other blogs, but some are real-world situations that you might find useful to know about or perhaps even entertaining.</p><p>So here I go….</p><h4>Part 1: Evolution and Vendor Support</h4><p>I started developing Azure Functions around 2017 in C# with Net Framework (I know I know this is like archeology in 2023), but at the time this was the only option from MS and Net Core although wildly available at the time, was very new for Azure Functions. Over time we migrated all of these to Net Core, ending up at Net 6 in 2023. And, this is what I consider was the weakest point about Azure functions from MS.</p><p>Also, Azure Functions in Net Framework (aka v1) did not have the full-fledged integration with App Insights, so we could only see “requests” into the apps, but not “dependencies” going out, so observability became a deficit from day #1.</p><p><em>Some context</em>: The reason why we started using Azure Functions around 2017 was that for our customer, Virtual Machines or AppServices were too expensive, so one day, an almighty Architect woke up from its bed and yelled “eureka” we are going to transform all our AppServices into Azure Functions (<strong>because these are free</strong>). <strong>*P.1.1</strong>=Try to remember this statement, I will get back to this later.</p><p>Eventually we migrated these from v1 to v2, from v2 to v3 and finally to v4 in Net 6. Why? simply because MS said every 1 or 2 years that the older frameworks were becoming obsolete and wouldn’t have any support anymore. But was the migration effortless? Not at all, some were complete re-writes and <strong>were very expensive *P.1.1 </strong>from a project’s budget point of view of course<strong>.</strong></p><p>In terms of performance, security or functionality, I don’t recall seeing any major improvements in these Azure Functions, there might have been some (full support for requests and dependencies in app insights was a given), but we never needed any particular improvements. We just had to keep pace with the new releases because MS said so or we would be running unsupported code in production (As I write this I am already planning on writing a special article on the Net 6 migration Azure functions which was a special case in its own right).</p><p><em>Side note: </em>So if you read between the lines here, we became slaves to MS’ release schedule for new Azure Function frameworks, all in hope of getting rid of appservices to reduce costs <strong>*P.1.1 </strong>(the irony is implied)<strong>.</strong></p><p>Now how can I compare this experience of an “evolution-path” with AWS Lambdas? I recently started with Lambdas in .Net, Java and to a minor degree in Node Js, but I can’t say I have 7 years of experience with Lambdas. But browsing the internet and using some common sense, I haven’t seen any articles “demanding” companies to migrate from AWS v.x to v.x+1, simply because such a thing doesn’t exist in AWS. But AWS keeps a “deprecation policy” about the language frameworks / runtimes for Lambdas, namely here: <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html">https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html</a></p><p>Read the above page, and you will see the following sentence “<em>Phase 2 — you can no longer </em><strong><em>create or update</em></strong><em> functions that use the runtime.</em>” . In my understanding this means: you would end up with code in production that can no longer be modified until you upgrade the framework/runtime <strong>(*Oct 2024 update)</strong>. So IMHO, when comparing to MS’ policy, I prefer MS’ one. At least with Azure Functions you can keep on developing your unsupported code much much longer, at your own risk of course.</p><blockquote><strong>*Oct 2024 update = </strong>I just had the opportunity of creating a Cloudwatch dashboard custom widget with a Lambda and it got created as a node js 16 lambda which is totally unsupported in 2024. However, I did my own Cloudformation script creating that widget as a Node Js 16 app and it worked. Meaning, AWS won’t let you <strong>manually</strong> create lambdas for deprecated frameworks, but still create them with automation tools.</blockquote><p>A difference with AWS though, is that you can create your own custom “runtime”, which according to my understanding of the deprecation policy, it wouldn’t be ever get into the “phase 2”, since that’s your own thing to support (a self managed Lambda so to say).</p><p>Another major fact about the evolution paths of these 2 technologies, is that MS started Azure Functions as “Consumption Plan”, then Premium and then probably Dedicated (I don’t have a recolection of what came out first exactly), whereas in AWS I don’t even see such a taxonomy existing today.</p><p>The 3 flavours of Azure Functions are a migration path for development teams to embrace, because:</p><ul><li>Azure Functions in consumption plan are free up to a million requests, but after that they can become expensive. They can have very slow startup times (cold-starts) and are limited on connectivity and scalability configurations.</li><li>Premium are not free and guarantee startup times of new instances or provide warm instances. Scalability options are more manageable.</li><li>Dedicated are basically AppServices with fixed costs and all scalability options available on AppServices. Now, this is a catch. Is an Appservice serverless? Most likely not, you are too much involved in defining a plan, scale out policies, etc. But this is a subject for another blog.</li></ul><p>AWS Lambdas, don’t provide these 3 types because:</p><ul><li>You are always charged for the time you use them</li><li>If you want to provide better performance or availability you can increase memory, CPU arquitecture, storage, or warm instances with concurrency options.</li></ul><p>In this sense AWS Lambdas are better suited to handle extreme load, however you must make sure that your account is configured to scale out Lambdas to the level you are expecting to support.</p><p>One big difference on the subject of Vendor Support, is that although both have very clear SLAs, there is no mention in Azure Functions’ credits for issues while running them during the free period. In other words, <strong>if you are not charged for a service, you can</strong>’<strong>t complain about failures. </strong>Now another grey area, is how to prove a failure, which is a chapter on its own.</p><p>About tech support calls, in my recent experience with AWS, I can only say their level of support has been great so far, but I must admit my employer paid an extra for developer support. As for MS’ support, even being on a premium support tier, I found their service level barely acceptable. Over the years with MS we had many failures related to patches applied to AppServices (not Azure Functions per se), connectivity issues <strong>*P.1.2</strong> and the response was, although completely valid, in most cases “upgrade to the latest SDK” or latest Azure Function version.</p><p><strong>*P.1.2=Another topic I will reference in the future.</strong></p><p>Extreme cases I have seen in Azure with all services are those when Azure “injects” errors between HTTP communications, your applications log them because a developer said “let’s log the http status of a failure” but never thought of logging the response text (there was no requirement in a user-story to do so :-)). So a 400 http status coming back from a service (being an Azure Function or not) could have been generated by the Application itself or by Azure. I have seen development teams spending days or weeks trying to reproduce such a case, until somebody said let’s log the response, which when finally found again said “Azure Network error, Azure Server Error”, etc. These are the cases that are almost impossible to get support for by the vendor (another case of <strong>*P.1.2 syndrome)</strong></p><p>That, I haven’t heard of with AWS yet — touch wood.</p><p>Managed “patches”: this is an interesting topic that I haven’t heard or read being discussed much. All cloud providers have the buzzword “managed service”, which simply means: the provider is going to take care of the basic maintenance needed to have your services running with the latest and most secure code (patches) and with a proper configuration and monitoring to guarantee a very high degree of availability (and luckily keep you informed of deprecations and guide you on migration paths :-).</p><p>Now one interesting difference with AWS Lambdas and Azure Functions, is that both run on Operating Systems that need to be patched now and then. And here comes the difference: AWS Lambdas do only run as one instance for the time they are running a function, in other words “one request maps to one new server instance” every time. Of course an already running instance, can be re-used and called upon many times, until it finally unloads (a docker container in the end). So, all this this means, <strong>you cannot have an AWS Lambda image serving multiple requests at the same time.</strong></p><p>With Azure Functions this is exactly the opposite. Azure functions serve as many requests as they can on each instance and once the instance becomes overloaded (and performance deteriorates), new traffic is not rejected but not connected to the overloaded instance, a new intance is then created and the paused traffic is then redirected to the new instance.</p><p>There is nothing wrong with both approaches, actually MS’ one makes perfect sense if they are offering you a free service (Consumption Plan), and since AWS always charges for the time consumed, makes also sense to provide some predictable throughput, which MS lacks when sharing an instance.</p><p>But about patches? MS has some articles explaining that APP Services should ideally be grouped as odd numbers of instances, e.g. 3 servers running in parallel (optionally more dynamically to scale out) because patches are applied on pairs of servers, this means a set of 2 servers are usually shutdown and patches applied, so if you have 3, you will always have at least one responding. So the same rule applies to Azure Functions in Dedicated mode. Now for Consumption plan or Premium, this is a big question mark. For example if we had 10 users being served on one instance of a Consumption or Premium instance and MS suddenly patches a server and reboots it, we would get 10 failed requests. This is not uncommon to see with any of the Azure Function types, but then again try to prove this happened to you and good luck trying to get some support for this, basically because you will not be told when a server was patched (this is all serverless, there are no servers, right? :- pun intended).</p><p>Now with AWS Lambdas, patches are also applied. I haven’t heard yet of anyone complaining of a server being shutdown in the middle of an operation, nor any rule about keeping uneven/odd numbers of servers running on a given concurrency setup, however by applying just some common sense, if every request is one server instance, then the chances of harming production operations by a server suddently restarting due to a patch or whatever reason is much lower than with Azure Functions.</p><p>Ok I think this is it for Part 1, I hope you found this article interesting,<br>thank you for reading. <br>Boris J.</p><p><strong>New: Part 2 is available </strong><a href="https://medium.com/@bajani2007/to-be-serverless-or-not-d546d7343315"><strong>here</strong></a><strong>.</strong></p><p>References and other good stories:<br>- <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html?icmpid=docs_lambda_console">https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html?icmpid=docs_lambda_console</a> <br>- <a href="https://iamondemand.com/blog/aws-lambda-vs-azure-functions-ten-major-differences/#:~:text=AWS%20Lambda%20charges%20for%20full,may%20lead%20to%20noticeable%20reductions">https://iamondemand.com/blog/aws-lambda-vs-azure-functions-ten-major-differences/#:~:text=AWS%20Lambda%20charges%20for%20full,may%20lead%20to%20noticeable%20reductions</a></p><p><em>Legal Disclaimer: The views and opinions expressed here are those of the author only and do not necessarily reflect the views or positions of any other entity that the author has or has had any relation with.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fef4590c79c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>