<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kamlesh Bambarde</title>
    <description>The latest articles on DEV Community by Kamlesh Bambarde (@rustoncloud).</description>
    <link>https://dev.to/rustoncloud</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F388429%2Fe9995249-24b1-4b59-b13a-a9449718bae5.jpg</url>
      <title>DEV Community: Kamlesh Bambarde</title>
      <link>https://dev.to/rustoncloud</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rustoncloud"/>
    <language>en</language>
    <item>
      <title>Performance Comparison of C#, Node, Java, Go &amp; Rust on k8s</title>
      <dc:creator>Kamlesh Bambarde</dc:creator>
      <pubDate>Sun, 26 Nov 2023 07:52:34 +0000</pubDate>
      <link>https://dev.to/rustoncloud/performance-comparison-of-c-node-java-go-rust-5gbh</link>
      <guid>https://dev.to/rustoncloud/performance-comparison-of-c-node-java-go-rust-5gbh</guid>
      <description>&lt;p&gt;In continuation to my &lt;a href="https://dev.to/rustoncloud/sustainable-cloud-computing-using-rust-language-4m82"&gt;earlier post&lt;/a&gt; about using Rust Language for sustainable cloud computing, here, in this post, I would like to present comparison of facts like the CPU &amp;amp; Memory utilisation by languages like C#, NodeJS, Java, Go &amp;amp; Rust on k8s. &lt;/p&gt;

&lt;p&gt;To perform this comparative study, I developed very basic Rest Api's in all these languages that serve exactly similar kind of data. All these Rest Api's are built based on the project template of ASP.Net Core Web Api, yes, the WeatherForeCast, containerised, deployed to Kubernetes and exposed using NGINX Ingress Controller.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Frameworks Used&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Language&lt;/th&gt;
&lt;th&gt;Framework&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;C#&lt;/td&gt;
&lt;td&gt;ASP.Net Core&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java&lt;/td&gt;
&lt;td&gt;SpringBoot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Node&lt;/td&gt;
&lt;td&gt;ExpressJS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;Fiber&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;Warp&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Test Environment;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Apple MacBook Air M1 with 8GB RAM&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://microk8s.io/"&gt;Microk8s&lt;/a&gt; by Canonical &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/wg/wrk"&gt;wrk&lt;/a&gt; for Stress Testing &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;k8s Deployment Resource Limits;&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Language&lt;/th&gt;
&lt;th&gt;Request CPU&lt;/th&gt;
&lt;th&gt;Request Memory&lt;/th&gt;
&lt;th&gt;Limit CPU&lt;/th&gt;
&lt;th&gt;Limit Memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;C#&lt;/td&gt;
&lt;td&gt;250m&lt;/td&gt;
&lt;td&gt;32M&lt;/td&gt;
&lt;td&gt;500m&lt;/td&gt;
&lt;td&gt;64M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java&lt;/td&gt;
&lt;td&gt;250m&lt;/td&gt;
&lt;td&gt;128M&lt;/td&gt;
&lt;td&gt;500m&lt;/td&gt;
&lt;td&gt;256M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Node&lt;/td&gt;
&lt;td&gt;250m&lt;/td&gt;
&lt;td&gt;32M&lt;/td&gt;
&lt;td&gt;500m&lt;/td&gt;
&lt;td&gt;64M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;250m&lt;/td&gt;
&lt;td&gt;32M&lt;/td&gt;
&lt;td&gt;500m&lt;/td&gt;
&lt;td&gt;64M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;250m&lt;/td&gt;
&lt;td&gt;32M&lt;/td&gt;
&lt;td&gt;500m&lt;/td&gt;
&lt;td&gt;64M&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Stress Test Parameters&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Threads - 12&lt;/li&gt;
&lt;li&gt;Connections - 400&lt;/li&gt;
&lt;li&gt;Duration - 30 Seconds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Stress Test Results&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Language&lt;/th&gt;
&lt;th&gt;Total Requests&lt;/th&gt;
&lt;th&gt;Throughput&lt;/th&gt;
&lt;th&gt;Data Received&lt;/th&gt;
&lt;th&gt;Transfer Rate&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;C#&lt;/td&gt;
&lt;td&gt;451463&lt;/td&gt;
&lt;td&gt;15006/sec&lt;/td&gt;
&lt;td&gt;288MB&lt;/td&gt;
&lt;td&gt;9.56MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java&lt;/td&gt;
&lt;td&gt;57992&lt;/td&gt;
&lt;td&gt;1928/sec&lt;/td&gt;
&lt;td&gt;41MB&lt;/td&gt;
&lt;td&gt;1.35MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Node&lt;/td&gt;
&lt;td&gt;104504&lt;/td&gt;
&lt;td&gt;3472/sec&lt;/td&gt;
&lt;td&gt;67MB&lt;/td&gt;
&lt;td&gt;2.23MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;595449&lt;/td&gt;
&lt;td&gt;19815/sec&lt;/td&gt;
&lt;td&gt;392MB&lt;/td&gt;
&lt;td&gt;13.05MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;672391&lt;/td&gt;
&lt;td&gt;22344/sec&lt;/td&gt;
&lt;td&gt;467MB&lt;/td&gt;
&lt;td&gt;15.52MB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Resource Utilisation in Idle and Stressed State&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Language&lt;/th&gt;
&lt;th&gt;Idle CPU&lt;/th&gt;
&lt;th&gt;Idle Memory&lt;/th&gt;
&lt;th&gt;Stressed CPU&lt;/th&gt;
&lt;th&gt;Stressed Memory&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;C#&lt;/td&gt;
&lt;td&gt;1m&lt;/td&gt;
&lt;td&gt;35Mi&lt;/td&gt;
&lt;td&gt;483m&lt;/td&gt;
&lt;td&gt;45Mi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java&lt;/td&gt;
&lt;td&gt;1m&lt;/td&gt;
&lt;td&gt;129Mi&lt;/td&gt;
&lt;td&gt;500m&lt;/td&gt;
&lt;td&gt;228Mi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Node&lt;/td&gt;
&lt;td&gt;1m&lt;/td&gt;
&lt;td&gt;30Mi&lt;/td&gt;
&lt;td&gt;500m&lt;/td&gt;
&lt;td&gt;41Mi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;1m&lt;/td&gt;
&lt;td&gt;7Mi&lt;/td&gt;
&lt;td&gt;465m&lt;/td&gt;
&lt;td&gt;17Mi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;0m&lt;/td&gt;
&lt;td&gt;0Mi&lt;/td&gt;
&lt;td&gt;352m&lt;/td&gt;
&lt;td&gt;9Mi&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Observations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All the Rest Api's that I deployed to k8s, k8s was able to spin up the pods, but not Java SpringBoot based Rest Api pod. k8s was failing to spin up the Java SpringBoot based Rest Api pod for [OOMKilled] error, I had to then increase the memory from request 32M to 128M and limit from 64M to 256M. Despite the fact that SpringBoot deployment was configured with more memory than other deployments, its worst in throughput.&lt;/p&gt;

&lt;p&gt;To my pleasant surprise ASP.Net Core pod was able to run with request memory of 32M and limit memory of 64M and much better throughput as compared to SpringBoot. Microsoft has definitely done a tremendous job at improving .NET Runtime in terms of the memory requirements and its utilisation even the garbage collection post stress test was faster than Java.&lt;/p&gt;

&lt;p&gt;In an idle state all the frameworks were consistently eating up 1m core of CPU and that's the need of GC background thread, where as Rust was 0m.&lt;/p&gt;

&lt;p&gt;Go Fiber implementation was somewhere closer to Rust Warp implementation from throughput perspective, was consuming close to 25% more CPU.&lt;/p&gt;

&lt;p&gt;Node Express based Rest Api was much better compared to SpringBoot based Api, almost double the throughput.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What can you build using Rust?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rust can be used to develop applications for cloud, Microservices, Azure Functions, AWS Lambdas. There are number of Rust Crates (packages) available to build applications for cloud, some of the widely used ones are listed below.&lt;/p&gt;

&lt;p&gt;Web Frameworks&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://crates.io/crates/warp"&gt;Warp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://crates.io/crates/axum"&gt;Axum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://crates.io/crates/actix-web"&gt;Actix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://crates.io/crates/rocket"&gt;Rocket&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://crates.io/crates/tide"&gt;Tide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ORM&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://crates.io/crates/diesel"&gt;Diesel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://crates.io/crates/sea-orm"&gt;SeaORM&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Database Clients&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://crates.io/crates/sqlx"&gt;SQLX&lt;/a&gt; (supports MS Sql, MySql, PostGres &amp;amp; SqlLite)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additionally, both Amazon and Microsoft has sdk for Rust to utilise services from their respective cloud platforms. Microsofts Azure sdk for Rust is part of Azure organisation on GitHub, but it's, still under heavy development and not official yet.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Azure/azure-sdk-for-rust"&gt;Azure sdk for Rust&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/awslabs/aws-sdk-rust"&gt;AWS sdk for Rust&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Is it easy to adopt Rust?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No, not at all, Rust is a language that has a very steep learning curve, lot of new stuff at conceptual level. &lt;/p&gt;

&lt;p&gt;Not very long ago, Java too, was considered little difficult adopt for people who were trying to shift from procedural languages to Java. But with proper trainings and mentoring, people gained the required level of skills, so, the same is applicable to Rust.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As you can clearly make out from the about test results, that Rust outperforms every other language &amp;amp; framework in both throughput and resource utilization. &lt;/p&gt;

&lt;p&gt;Languages like, Java, C#.NET, JS on Backend have served their purpose in an era where the world was getting into the internet based apps from desktop based apps. Now, that most of the IT workloads are moving to Cloud, it has become imperative to use modern languages like Rust that uses less resources, saves compute cost on cloud and more importantly, emits less carbon which results in to a lesser impact to our planet.&lt;/p&gt;

&lt;p&gt;You can get all the source code and k8s manifests in my Git Repository, request me in comments for the same.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Sustainable Cloud Computing Using Rust Language</title>
      <dc:creator>Kamlesh Bambarde</dc:creator>
      <pubDate>Sun, 26 Nov 2023 07:51:45 +0000</pubDate>
      <link>https://dev.to/rustoncloud/sustainable-cloud-computing-using-rust-language-4m82</link>
      <guid>https://dev.to/rustoncloud/sustainable-cloud-computing-using-rust-language-4m82</guid>
      <description>&lt;p&gt;Sustainable Cloud Computing is an ecologically conscious and sustainable method to utilise cloud computing resources. Its main objective is to reduce the energy consumption by various cloud services and thereby the environmental effect of data centers.&lt;br&gt;
Sustainable cloud computing benefits not only the environment but also organisations that rely on cloud services. By using environmentally friendly Platforms/Frameworks/Languages to build their services to run on cloud platforms, businesses can align their IT infrastructure with their sustainability goals and potentially reduce operational costs. It’s also an essential part of the broader effort to address the environmental impact of the IT industry and promote a more sustainable future.&lt;br&gt;
Following are some of the Key principals of Sustainable Cloud Computing, where Rust can help achieve maximum benefits.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Energy Efficiency&lt;/li&gt;
&lt;li&gt;Resource Management&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Rust Language&lt;/strong&gt;&lt;br&gt;
Rust, a systems programming language developed at Mozilla by Graydon Hoare back in 2006. It was heavily influenced by the ideas from functional programming like immutability and algebraic data types etc. Though, Rust was mainly developed as a replacement of C++, but over the period of time it has acquired a convenience of high-level languages, which makes it possible to be used for the development of services that run on cloud platforms.&lt;br&gt;
Following are some of the reasons for which Rust is increasingly being used in the context of sustainable cloud computing:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Performance and Efficiency:&lt;/strong&gt; Rust is made to guarantee memory safety while offering low-level control over system resources. It is therefore a cost-effective option for developing services that run under cloud environment. Efficiency is a significant consideration in sustainable cloud computing since it may assist reduce energy consumption and optimize resource usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Memory Safety:&lt;/strong&gt; Rust’s ownership and borrowing model of memory management can significantly help eliminate issues like null pointer dereferences and data races. The memory safety provided by Rust, enables developers to fearlessly write concurrent code that is both safe and efficient. As a result, there may be less need for resource-intensive error handling and debugging, leading to more stable and dependable cloud services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Energy Efficiency:&lt;/strong&gt; Rust’s emphasis on performance frequently results in code that uses less energy. Rust can contribute to lowering the overall energy usage of cloud services by decreasing the computational resources needed to complete activities. This is one of the most impending reasons for choosing Rust over other languages to develop services that run on Cloud Platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reduce Resource Consumption:&lt;/strong&gt; Rust’s resource management features can assist developers in making the best use of CPU, memory, and other resources, therefore reducing the environmental impact.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Rust’s architecture makes it ideal for creating scalable and highly concurrent systems, which are critical in cloud computing environments. Minimising the number of CPUs and amount of RAM needed can help significantly reduce the overall environmental impact of cloud computing.&lt;br&gt;
Long-Term Maintainability: Long-term software system sustainability is a component of sustainable cloud computing. Because of its robust type system and emphasis on memory safety, Rust can facilitate the evolution and maintenance of services that run in a cloud environment over time, minimising the need for resource-intensive rewrites or replacements.&lt;br&gt;
Open Source Ecosystem: Rust has a strong open-source community and ecosystem, which can foster the development of sustainable cloud computing solutions and encourage collaboration on eco-friendly initiatives.&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/rustoncloud/performance-comparison-of-c-node-java-go-rust-5gbh"&gt;next part&lt;/a&gt; of we will look at the evidence of how Rust is better compared to other languages from the perspective of resource utilisation and efficiency.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
