<?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 Mustafa Başaran on Medium]]></title>
        <description><![CDATA[Stories by Mustafa Başaran on Medium]]></description>
        <link>https://medium.com/@bermuda_writer?source=rss-5497eb13b0f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9xirLFoeq810zzEEGICK0g.png</url>
            <title>Stories by Mustafa Başaran on Medium</title>
            <link>https://medium.com/@bermuda_writer?source=rss-5497eb13b0f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 17:36:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bermuda_writer/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[Bir Garip AWS Hikayesi]]></title>
            <link>https://medium.com/bermuda-technology/bir-garip-aws-hikayesi-fb45b1900aca?source=rss-5497eb13b0f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb45b1900aca</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Mustafa Başaran]]></dc:creator>
            <pubDate>Thu, 06 Feb 2020 13:10:04 GMT</pubDate>
            <atom:updated>2020-02-07T07:31:15.729Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@tufand/an-interesting-aws-story-2b81dc7c6c5">Click here to read in English</a></p><p>Selamlar,</p><p><a href="http://bermuda.com.tr/">Bermuda</a> ekibi olarak bir süredir sigortacılık alanında faaliyet gösteren Amerikalı müşterimiz için, sigorta şirketlerinin api entegrasyonları üzerinden müşterilerine teklif sunma sürecini uçtan uca yönetecek çözümü geliştiriyoruz.</p><p>Kısaca proje ve kapsamından bahsetmek istiyorum çünkü; AWS deneyimlerimiz projede kullandığımız farklı teknolojileri bir araya getirmek ile yakından ilgili ve belki benzer teknolojileri kullanarak yola çıkacaklar için güzel bir örnek olabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*9PYpWovgLdrT-E1qH0xCdA.jpeg" /></figure><p>Proje kapsamında, teklif alma sürecini ve kurumsal iletişim hizmetini sunan iki farklı web uygulaması, web uygulamalarına servis sağlayan web api ve geçmiş teklifler ile eğitilen ve eğitilmeye devam eden ML hizmetini tasarladık.</p><h3>.Net Core Api &amp; Python &amp; Machine Learning &amp; React &amp; PostgreSQL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*upKXn09kmimmskNkzbUJnw.jpeg" /></figure><p>Bu yapı da teklif alma ve kurumsal iletişim uygulamasını React, Rating Api tarafında .Net Core ve müşterilere son adıma ulaşana kadar girdikleri bilgilerinden tahmini bir fiyat göstermek için kurguladığımız Machine Learning Api için de Python kullanıyoruz. Veri tabanı olarak ise PostgreSQL kullanmayı tercih ettik.</p><p>Proje için önemli bir yere sahip olan ML modelini eğitebilmek için sigorta şirketlerinin daha önceden vermiş olduğu fiyat tekliflerini kullandık. .Net Core Api IHostedService mimarisini kullanan Scheduler Job kütüphanesi ile düzenli aralıklarla sigorta şirketlerinden teklifleri çekip, Python Api üzerinden ML modelinin sürekli olarak eğitilmesini sağlıyoruz. Bu sayede Quote Web uygulaması ile teklif almak için bilgilerini giren müşteriye en son adıma ulaşıp gerçek sigorta şirketinden teklif alana kadar kendisine tahmini bir fiyat bilgisini yanılma payı ile birlikte gösteriyoruz.</p><p>Buraya kadar her şey güzel, analiz sürecinden sonra başladığımız geliştirme aşamasında test ortamı olarak kullandığımız Linux sunucumuz üzerinde tüm uygulamaları kendimiz yönetip müşteri sunumlarını sürdürüyorken, daha fazla ölçekleme için canlı sistemde AWS veya Azure kullanmayı düşündük. Müşterinin bazı başka sistemlerinin AWS’de olmasından dolayı AWS tarafı daha ağır bastı.</p><p>Bir Türk şirketi olarak; müşteri bizim için her zaman haklıdır :) o ne derse o olur mottosu ile başladık AWS araştırmaya, takdir edersiniz ki bir kulak aşinalığı var ama tecrübe edinmek başka bir şey, bir de uygulamaların AWS Lambda üzerinde koşmasını istedikleri için; uygulamalarımızı nasıl AWS ortamında Lambda ile çalıştırırız onu araştırmaya başladık.</p><h3>Sunucu Yok!</h3><p>Sunucusuz bir mimari kavramını teorik bilgiden pratiğe çevirmeye çalıştığımız sıra da aşina olduğumuz bazı şeyleri ararken aklımıza Vizontele filmindeki bu sahne geldi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_f9qUihwoDZEo2k4-Flv1A.jpeg" /></figure><p>Ne demek sunucu yok?</p><p>Dosya sistemine yazdığımız logları ya da .config dosyasına yapacağımız bir değişiklik için uygulama dosyalarının barındığı yeri görmek istiyoruz. Karşımıza S3 (Simple Storage Service) çıkıyor. S3 uygulamanıza ait dosyaları üzerinde tutuyor ama, buraya güncel dosyaları atıp uygulamayı restart ederek güncellemek gibi bir yaklaşım Lambda için söz konusu değil, zaten S3 ortak dosya saklama servis hizmeti; uygulamaları (UI projeleri haricinde) execute eden bir server ortamı olarak kullanılmıyor.</p><h3>Deployment</h3><p>Uygulamanızı kurmak ya da güncellemek için geliştirme ortamına uygun bir Tool kullanmanız ya da AWS CLI ile uygulama dosyalarınızı AWS Lambda üzerine deploy etmeniz gerekiyor.</p><p>React geliştirmesini yapan arkadaşlar, ilk olarak; web tarafını S3 üzerine zip ile paketleyip deploy etmeyi düşündüler, serverless framework kullanamayacakları ve her şeyi kendileri yönetmek zorunda kalacakları <br>için bu yöntemden vazgeçtiler. Ardından, Next.js lambda serverless framework kullanmayı denemeye başladılar. Bu sefer de Next.js serverless çalışabilmesi için her sayfa özelinde hazırlanacak olan lambda function, o sayfaya ait tüm npm paketleri, paketlerin bağımlılıkları gibi bir gereksinim ortaya çıkmaya başladı ve bu yöntem her bir sayfanın 50MB üstüne çıkmasına neden oluyordu. Kısa bir araştırmadan sonra Quote (React.js) projesini AWS CloudFront üzerine taşırken, Web (Next.js) kısmı için ise <a href="https://slack-redir.net/link?url=http%3A%2F%2FZeit.co">Zeit.co</a> kullanmaya karar verdik.</p><p>React tarafı bir iki gün kadar test sunucumuza bakarak çalıştı biz de bu sırada .Net Core ve Python tarafını Lambda üzerine kurma ile ilgili araştırmaları sürdürdük.</p><p>Örnekleri incelediğimizde Visual Studio üzerine <a href="https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.AWSToolkitforVisualStudio2017">AWS Toolkit</a> yükleyerek publish yapabileceğimizi okuduk ve ilgili eklentiyi yükledik. Bizim projemiz başlangıçta AWS Template olarak oluşturulmadığı için publish aşamasına hemen geçemedik. Visual Studio üzerine yüklenen Toolkit proje create etme aşamasında AWS için Template oluşturma imkanı sağlıyordu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJgaMioZVSLrQETJnHtBbw.jpeg" /></figure><p>Mevcutta Application olarak çalışan proje katmanını yeni bir AWS Template üzerine taşımak yerine boş bir AWS Template açıp olması gereken kütüphaneleri, .csproj şablon yapısını kendi projemize uyarladık. Örnekleri inceleyerek, serverless.template ve aws-lambda-tools-defaults.json içeriklerini de yine projemize uygun şekilde oluşturduk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wN7QAGoZGW7IEBVhOQXw2Q.jpeg" /></figure><p>Dikkat ederseniz proje .Net Core 2.2 framework kullanıyor demiştim. AWS Lambda için .Net Core 2.1 kullanmamız gerekiyordu çünkü; ortamlarında 2.1 framework için destekleri bulunuyordu. İlk olarak projeyi 2.1 versiyona downgrade etmek istemedik. Bu hem zahmetli hem de teknik açıdan bize sorun çıkaracağı için vazgeçtik.</p><p>.Net Core 2.2 framework ile çalışmanın bir yolu olup olmadığını araştırdık. <a href="https://aws.amazon.com/tr/blogs/developer/announcing-amazon-lambda-runtimesupport/">https://aws.amazon.com/tr/blogs/developer/announcing-amazon-lambda-runtimesupport/</a> adresinde konuya açıklık getirmişlerdi. Benzer taleplerin kendilerine iletildiğini, .Net Core 2.2 ve 3.0 desteği için Amazon.Lambda.RuntimeSupport geliştirdiklerini bunu kullanarak projeyi .Net Core 2.2 ile AWS Lambda üzerinde çalıştırabileceğimiz anlatılıyordu. Anlatıldığı gibi projede ilgili geliştirmeleri yapıp denedik ve AWS Lambda üzerine uygulamayı publish etmeyi başardık.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*dovM5S0n8rltlRuhHCY9Dw.gif" /></figure><p>Başardık dedim ama projenin ayağa kalkması ile tekrar kapanması bir oluyordu. Sebeplerini araştırdık, AWS CloudWatch yardımı ile uygulamanın ne yaptığını takip edip, neden durduğuna dair bir ipucu görmeye çalıştık. Üzerine gidebileceğimiz bir sorun görünmüyordu.</p><p>Araştırmaya devam etmek mi? Yoksa .Net Core 2.1 downgrade edip denemek mi daha hızlı sonuca götürecekti diye düşünürken projeyi 2.1 olarak downgrade edip tekrar publish etmeyi denedik. Sonuç; yine hata aldık, bu sefer CloudWatch sorunun AWS RDS üzerinde oluşturduğumuz PostgreSQL veri tabanına bağlanmak ile ilgili olduğunu söylüyordu. AWS Security Group ayarlarını yaptıktan sonra tekrar denedik ve .Net Core Web Api ayağa kaktı.</p><p>.Net Core 2.2 versiyonunda aldığımız hatanın güvenlik ile ilgili olduğunu düşünmüyoruz çünkü; timeout süresi kadar bile api çalışamadan tekrar down oluyordu. Sorunun yapılandırma ile ilgili olduğunu düşünüyoruz yeni bir proje açıp Amazon.Lambda.RuntimeSupport ile test etmek aklımızın bir köşesinde duruyor bunu müsait bir vakitte deneyip sorunun ne olduğunu anlamaya çalışacağız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1ygW2lV2s3a7a3NWZZJHQ.jpeg" /></figure><p>.Net Core Web Api projesini deploy işleminden sonra AWS API Gateway ekranı ile test ettik. Projenin çalışma mantığı da zaten üstteki şekilde olduğu gibi, dışarıya API Gateway ile açılıyor ve gelen istekler Lambda Function üzerine API Gateway aracılığı ile iletiliyor.</p><h3>Sıradaki Gelsin</h3><p>Sıra Python ile çalışan Machine Learning projesini ayağa kaldırmaya geldi. .Net Core ile yaşadığımız deneyimler AWS ortamına biraz daha ısınmamızı sağladığı için enstrümanları nasıl kullanmamız gerektiğini daha iyi kavradık diyebilirim.</p><p>Python projesi; Flask, Flasgger, XGBoost ve Pandas kütüphanelerini kullanıyor ve bu kütüphaneler de hatırı sayılır yer kaplıyorlar, nasıl deploy ederiz diye araştırırken birden fazla yöntemin içerisinden en zor olanı; Python projesini zip olarak paketledikten sonra AWS Lambda Function içerisine upload etmeyi seçtik :)</p><p>Bunu yapabilmek için öncelikle Linux üzerinde Python projesi için Virtual Environment oluşturup proje ve bağımlı olduğu kütüphaneleri buraya indirdik. Python Api bu ortam üzerinde çalıştıktan sonra tüm projeyi zip olarak paketledik. Dosya boyutu 10 MB üstüne çıktığı için AWS Lambda Function yapısı gereği, Python dosyalarını önce AWS S3 üzerine upload edip daha sonra S3 dizin adresini Lambda Function katmanında gösterdik.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*b3GbHjchSPd-1BTPPumbvg.jpeg" /></figure><p>Çalıştı mı? Tabi ki hayır.</p><p>Sıkıştırılmış dosya boyutunun 50 MB altında olmasını istedi.</p><p>Peki, Virtual Environment ile indirmiş olduğumuz paketleri çıkaralım ve sadece Python dosyalarını yükleyelim, paketleri de AWS Lambda Function Layer olarak ekleyelim dedik. Dediğimiz gibi de yaptık.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*OR8t2H1UMEoWJwkpofGEWA.jpeg" /></figure><p>Görüyorsunuz anlatmaya gerek yok, yerimiz dar oynayamıyoruz :) Paketler açıldıktan sonra ki boyut 250 MB sınırı üstüne çıktığı için yine olmadı.</p><p><a href="https://docs.aws.amazon.com/en_us/lambda/latest/dg/limits.html">https://docs.aws.amazon.com/en_us/lambda/latest/dg/limits.html</a> adresinden AWS Lambda limitlerinin güncel değerlerini görebilirsiniz.</p><h3>Zappa!</h3><p>Vazgeçtik mi? Tabi ki hayır tek atımlık bir mermimiz kaldı onu da kullanmadan vazgeçemezdik.</p><p>AWS Lambda limit değerlerinde /tmp directory storage için; 512MB desteklediği yazıyordu.</p><p><a href="https://blog.zappa.io/posts/slim-handler">https://blog.zappa.io/posts/slim-handler</a> adresinden bilgi edinebileceğiniz Zappa Serverless Framework Python projesinin deploy config dosyasını “slim_handler”: true olarak ayarladığınızda 500 MB sınırına kadar deploy edebildiğini yazıyordu. Zaten bu işlem için de üstte belirttiğimiz gibi /tmp dizinini kullanıyor. Gerekli ayarları yaptık ve Zappa ile deploy işlemini başlattık. AWS Lambda Function ve AWS API Gateway Zappa tarafından sırasıyla oluşturuldu. Deployment işlemi tamamlandıktan sonra genel olarak bir sorun görünmüyordu ve test aşamasına geçtik.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rH9whguLPOUUqMir7mDZOg.jpeg" /></figure><p>Zappa ile deneme de maalesef başarılı olmadı. Python projesi AWS Lambda üzerinde çalışmaya uygun olmadığı için AWS EC2 ile devam etmeye karar verdik. EC2 ile yeni bir Linux sunucu açıp Python projesini onun üzerinde çalışır hale getirdik.</p><p>.Net Core Web Api projemizi AWS Lambda, Python ML Api projemizi ise EC2 kullanarak müşterimiz için PreProd ortamında çalışır hale getirdik. Kullanım esnasında kendi test ortamımız ile AWS Lambda ortamı arasında ciddi bir performans farkı olduğunu tespit ettik.</p><h3>Cold Start</h3><p>Kendi test ortamımızda hiç takılmadan cevap aldığımız Api, AWS Lambda üzerinde fark edilir derecede yavaş çalışıyordu. Hatta bu bir issue olarak müşteri tarafından bize atandı ki sorunun nedeni; AWS Lambda mimarisinin Cold Start olarak bilinen şekliyle tüm .Net Core uygulamasını baştan başlatıyor olmasından kaynaklanıyordu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*hrXUW3MlJWkjh0zgoaA1xg.jpeg" /></figure><p>Bu sorunu aşmak için AWS Lambda sürekli bir instance hazır bekletmesine yönelik çözümler vardı fakat; aşağıdaki sıralayacağım nedenlerden dolayı pek içimize sinmedi.</p><p><strong>InMemory Cache:</strong> Bazı entegrasyonlardan sürekli aynı bilgileri çektiğimiz için cache kullandık. Proje kapsamında Distributed Cache kullanmak yerine InMemory cache ile ihtiyacımızı karşıladık. AWS Lambda kısa sürede down olduğu için InMemory cache kullanmamız bir işe yaramaz hale geldi. Bu sorunu Cache interface metotlarımızı implement eden sınıf içerisinde AWS Cache Mimarisine ait metotları kullanarak çözebilirdik.</p><p><strong>Scheduler Job: </strong>.Net Core IHostedService kullanarak çalışan Scheduler Job kütüphanesi proje ayağa kalkarken .config dosyasından okuduğu NCrontab çalışma zamanı bilgilerine göre ilgili olayları yerine getiriyordu. Projenin down olması zamanlanmış işlerinde durmasına neden oldu. AWS Lambda hizmetinin down olmaması için önerilen çözümler ile ya da Scheduler Job kütüphanesini ayrı bir proje içerisine alıp (proje yapımız buna müsait) EC2 üzerinde çalıştırarak bu durumu çözebilirdik.</p><p><strong>Function Timeout: </strong>Üstte saydığım ve bizi etkileyen iki maddeyi çözmeme nedenimizi bu madde ile açıklamaya çalışacağım. Kısa bir süre önce 5 dk’dan 15 dk. süresine uzatıldığını okuduğumuz function timeout kuralı bize pek çözülebilir bir sorun gibi gelmedi. Evet, 15 dk. bir function için çok uzun bir süre, bu kadar uzun süren bir iş yapar mıyız? Sanmıyorum, yapmıyoruz yapmayız da belki, ama bu durum 15 dk. süren bir işlemi biz bitiremezsek AWS Lambda tarafından bitirileceği gerçeğini değiştirmiyor.</p><h4>Sonuç: Biz bitti demeden bitmez!</h4><p>Evet, sonuç olarak AWS Lambda ölçeklendirme yapabilmek için Cold Start yaklaşımı ile çalışıyor. Bizim kurguladığımız mimarinin farklı zamanlar da pik yapmasına neden olacak bir senaryosu yok. ÖSS yerleştirme sonucu açıklama gibi misyonumuz olmadığı için EC2 üzerinde çalışmanın da bizim açımızdan sorun olmayacağına karar verdik.</p><h4>AWS Lambda kullanılabilir mi?</h4><p>Lambda amacının gerçekten “Function” olduğu, küçük ölçekli hızlı ayağa kalkıp işini bitiren global ölçekli küçük uygulamalar için (mikro servis mimarisi) daha elverişli olduğu sonucu çıkıyor. Uygulama mimarisini biraz daha fazla mikro servis olarak tasarlayarak Lambda üzerinde çok hızlı ölçeklenebilir uygulamalar yazılabilir.</p><p>Mümkün olduğunca yaşadıklarımıza ilişkin detay vermeye çalıştım. Umarım faydalı bir içerik olmuştur.</p><p>Faydalı olması dileğiyle.</p><p>Teşekkürler.</p><p>Tufan.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb45b1900aca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bermuda-technology/bir-garip-aws-hikayesi-fb45b1900aca">Bir Garip AWS Hikayesi</a> was originally published in <a href="https://medium.com/bermuda-technology">Bermuda Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Interesting AWS Story]]></title>
            <link>https://medium.com/bermuda-technology/an-interesting-aws-story-2b81dc7c6c5?source=rss-5497eb13b0f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b81dc7c6c5</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[net-core]]></category>
            <dc:creator><![CDATA[Mustafa Başaran]]></dc:creator>
            <pubDate>Thu, 06 Feb 2020 13:08:02 GMT</pubDate>
            <atom:updated>2020-02-06T13:18:05.693Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@tufand/bir-garip-aws-hikayesi-fb45b1900aca">Türkçe okumak için tıklayın</a></p><p>Hi Everyone,</p><p>As the <a href="http://bermuda.com.tr/">Bermuda</a> team, we are developing an end-to-end solution to manage the process of getting quotes from customers through API integrations for our American client, who has been working in the insurance sector for a long time.</p><p>I would like to briefly mention the project and its scope, as our AWS experience is closely related to bringing together the different technologies we have used in the project and may be a good example for those starting off using similar technologies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*9PYpWovgLdrT-E1qH0xCdA.jpeg" /></figure><p>Within the scope of the project, we designed two different web applications that provide the process of receiving quotes and corporate communication services, web API that provides service to web applications and the ML service, which has been and continues to be trained with past quotes.</p><h3>.Net Core Api &amp; Python &amp; Machine Learning &amp; React &amp; PostgreSQL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*upKXn09kmimmskNkzbUJnw.jpeg" /></figure><p>In this structure, we use .Net Core for Rating API for receiving quotes and React.js for Web &amp; Quote applications. And we use Python for Machine Learning API, which we designed to show customers an estimated price from the information they enter until they reach the final step. For the database, we preferred to use PostgreSQL.</p><p>To train the ML model, which has an important place in the project, we used the price quotes previously provided by insurance companies. With the Scheduler Job library, which uses the architecture of .Net Core API IHostedService, we regularly get quotes from insurance companies and ensure that the ML model is constantly trained on Python API. In this way, we show the estimated price information along with the error margin until the customer, who submits their information to get quotes via the Quote Web application, reaches the final step and receives an offer from the real insurance company.</p><p>Everything is fine so far. While managing all the applications and maintaining customer presentations ourselves on our Linux server, which we used as the test environment during the development phase after the analysis process, we thought about using AWS or Azure in the live system for further scaling. AWS tipped the scale, as some of the other systems of the client were on AWS.</p><p>As a Turkish company, we believe the customer is always right :) So, we started to do research for AWS with the motto of “whatever the client wants, that is how it should be”. We already had some familiarity, but as you would also agree, having experience is much better. As they wanted the applications to run on AWS Lambda, we started to do research on how we can run our applications with Lambda in AWS environment.</p><h3>No Server!</h3><p>We came up with this scene in Vizontele while we were looking for some familiar things when we were trying to move our serverless architecture knowledge from theoretical into practice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dElR5Q-1GTVxe4SOorQMJw.jpeg" /></figure><p>What do you mean, no server?</p><p>We want to see the log files we typed down on the file system or the location of the application files for changes to the config file. Here, we see S3 (Simple Storage Service). S3 keeps the files of your application on it, but in Lambda, you cannot upload the current files here and restart the application for the update to occur. S3 is a shared file storage service and cannot used as a server environment that executes applications (except for UI projects).</p><h3>Deployment</h3><p>To install or update your application, you need to use a Tool suitable for the development environment or deploy your application files on AWS Lambda with AWS CLI.</p><p>Our friends who performed the React development first thought to pack the web with zip on S3 and deploy it, but they then gave it up as they couldn&#39;t use serverless framework and they would need to manage everything themselves. Then, they started to try and use Next.js lambda serverless framework. This time, requirements such as a lambda function prepared for each page to get Next.js to work serverless, all npm packages of each page and their dependencies started to emerge, and this caused each page to exceed 50MB. After a brief research, we decided to use Zeitco for Web (Next.js) and Quote App (React.js).</p><p>The react worked for a day or so looking at our testing server. Meanwhile, we continued to work on setting up .Net Core and Python on Lambda.</p><p>When we examined the examples, we read that we could publish by installing AWS Toolkit on Visual Studio and installed the related extension. Since our project was not initially created as an AWS Template, we could not proceed to the publishing stage immediately. The Toolkit installed on Visual Studio provided the opportunity to create Templates for AWS during the project creation phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJgaMioZVSLrQETJnHtBbw.jpeg" /></figure><p>Instead of moving the project layer currently running as an Application onto a new AWS Template, we opened an empty AWS Template and adapted the .csproj template structure of the libraries to our own project. By examining the examples, we created serverless template and aws-lambda-tools-defaults.json contents in accordance with our project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wN7QAGoZGW7IEBVhOQXw2Q.jpeg" /></figure><p>As you will remember, I mentioned that the project is using a .Net Core 2.2 framework. We had to use .Net Core 2.1 for AWS Lambda, because they had support for the 2.1 framework. First, we did not want to downgrade the project to version 2.1. This would be both troublesome and technically problematic.</p><p>We investigated whether there was a way to work with .Net Core 2.2 framework. They clarified the issue at <a href="https://aws.amazon.com/tr/blogs/developer/announcing-amazon-lambda-runtimesupport/">https://aws.amazon.com/tr/blogs/developer/announcing-amazon-lambda-runtimesupport/.</a> They stated that similar requests were forwarded to them, that they were developing Amazon.Lambda.RuntimeSupport for .Net Core 2.2 and 3,0 support and that we could run the project on AWS Lambda with .Net Core 2.2. As explained, we have made the relevant improvements in the project and managed to publish the application on AWS Lambda.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*dovM5S0n8rltlRuhHCY9Dw.gif" /></figure><p>I said we made it, but once the project started up, it was closing again. We searched for the reasons, followed what the application did with the help of AWS CloudWatch and tried to find a clue as to why it stopped. It appeared that there was no problem we could work on.</p><p>As we debated what would help us get faster results, to keep researching? Or downgrade to .Net Core 2.1, we tried to downgrade the project to 2.1 and publish it again. The result: we got an error message again, and this time CloudWatch told us that the problem was about connecting to the PostgreSQL database we created on AWS RDS. After adjusting the AWS Security Group settings, we tried again, and .Net Core Web API worked.</p><p>We do not think that the error we got in .Net Core 2.2 was related to security, because the API would go down without even working until timeout. We think the problem is about the configuration, and it is in the back of our minds to open a new project and test it with Amazon.Lambda.RuntimeSupport. We will try this when convenient and try to understand the problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1ygW2lV2s3a7a3NWZZJHQ.jpeg" /></figure><p>We tested the .Net Core Web API project with AWS API Gateway screen after deployment. The working logic of the project is as above, it is opened to outside by API Gateway, and incoming requests are forwarded to Lambda Function via API Gateway.</p><h3>Next</h3><p>Now it was time to revive the Machine Learning project that runs with Python. Since our experiences with .Net Core allowed us to warm up to the AWS environment a bit, I can say that we could better understand how to use the instruments.</p><p>The Python project uses Flask, Flasgger, XGBoost and Pandas libraries, which take up considerable space. While doing research on how to deploy it, we chose to upload the most difficult one, to pack the Python project in zip and then to upload it into AWS Lambda Function :)</p><p>To do this, we first created a Virtual Environment for Python project on Linux and then downloaded the project and its dependent libraries here. After the Python API worked on this environment, we packed the whole project in zip. Since the file size exceeded 10 MB due to the AWS Lambda Function structure, we first uploaded the Python files onto AWS S3 and then showed the S3 directory address in the Lambda Function layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*b3GbHjchSPd-1BTPPumbvg.jpeg" /></figure><p>Did it run? Of course not.</p><p>It required the compressed file size to be under 50 MB.</p><p>Well, let’s just remove the packages that we downloaded with Virtual Environment and install the Python files and add the packages as AWS Lambda Function Layer. And we did so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*OR8t2H1UMEoWJwkpofGEWA.jpeg" /></figure><p>Needless to say, we have no room for maneuver here :) After opening the packages, it didn’t work again, as they exceeded the 250 MB limit.</p><p>you can see the current values of AWS Lambda limits at <a href="https://docs.aws.amazon.com/en_us/lambda/latest/dg/limits.html.">https://docs.aws.amazon.com/en_us/lambda/latest/dg/limits.html.</a></p><h3>Zappa!</h3><p>Did we give up? Of course not. We got one more in the chamber and weren’t about to give up without taking that shot.</p><p>The AWS Lambda limit values stated that it supports 512MB for /tmp directory storage.</p><p><a href="https://blog.zappa.io/posts/slim-handler">https://blog.zappa.io/posts/slim-handler</a> states that when we adjust the deploy config file of the Zappa Serverless Framework Python project as “slim_handler”: true, it could deploy up to 500 MB. As already mentioned above, it uses the /tmp directory for this process. We made the necessary adjustments and started deployment with Zappa. AWS Lambda Function and AWS API Gateway were created by Zappa. After deployment was completed, there seemed to be no problem, and we went ahead to the testing phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rH9whguLPOUUqMir7mDZOg.jpeg" /></figure><p>Unfortunately, the trial with Zappa was not successful either. Since the Python project was not suitable to run on AWS Lambda, we decided to continue with AWS EC2. We opened a new Linux server with EC2 and made the Python project run on it.</p><p>We made our .Net Core Web API project run on AWS Lambda and our Python ML API project run in PreProd environment using EC2 for our clients. During use, we detected a significant performance difference between our test environment and the AWS Lambda environment.</p><h3>Cold Start</h3><p>Giving response with no interruption in our own test environment, the API was running noticeably slower on AWS Lambda. So much that this was assigned to us by the client as an issue.The reason was due to the fact that the AWS Lambda architecture restarted the entire .Net Core application, known as a Cold Start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*hrXUW3MlJWkjh0zgoaA1xg.jpeg" /></figure><p>To overcome this problem, there were solutions for continuous AWS Lambda instance waiting. But, we didn’t feel OK with this for the following reasons.</p><p><strong>InMemory Cache:</strong> We used cache as we constantly pulled the same information from certain integrations. Within the scope of the project, we met our needs by using InMemory cache instead of Distributed Cache. Since the AWS Lambda went down shortly, using InMemory cache became useless. We could solve this problem by using the methods of AWS Cache Architecture within the class that implements our Cache interface methods.</p><p><strong>Scheduler Job: </strong>Working with .Net Core IHostedService, the Scheduler Job library was executing related events based on the NCrontab runtime information it read from the config file as the project was revived. The fact that the project went down caused it to stop scheduled work. We could solve this with the suggested solutions to avoid the AWS Lambda service to go down or by getting the Scheduler Job library into a separate project (our project structure is suitable for this) and running it on EC2.</p><p><strong>Function Timeout: </strong>I will try to explain the reason why we didn’t solve the two items above that affected us. The function timeout rule, which recently got extended from 5 minutes to 15 minutes, did not seem like a problem that could be solved. Yes, 15 minutes is a very long time for a function, are we going to do a job that takes so long? I don’t think so, we are not. But that doesn’t change the fact that if we don’t finish a process that takes 15 minutes, it will be finished by AWS Lambda.</p><h4>Conclusion: It’s not over until we say it is!</h4><p>Yes, in conclusion, AWS Lambda run with the Cold Start approach to be able to scale. The architecture that we designed does not have a scenario that will cause peaks at different times. We decided that running on EC2 would not be a problem for us since we did not have a mission, like, announcing the results of the student selection examination.</p><h4>Can AWS Lambda be used?</h4><p>It turns out that the Lambda really has the goal of “Function”, that it is more convenient for small-scale and fast-paced global applications (micro-service architecture). By designing the application architecture as a little more micro-service, very fast and scalable applications can be done on Lambda.</p><p>I tried to elaborate as much as I can on what we’ve been through. I hope it’s been a useful content.</p><p>Best wishes.</p><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b81dc7c6c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bermuda-technology/an-interesting-aws-story-2b81dc7c6c5">An Interesting AWS Story</a> was originally published in <a href="https://medium.com/bermuda-technology">Bermuda Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>