Ruby 3.2.0 enhances Regexp performance and security with ReDoS protections

What is ReDoS? Regular expression Denial of Service (ReDoS) is a security vulnerability that can occur in a regular expression (regex) when the regex is applied to a long string. This attack is designed to make a system or network unavailable to its intended users. An example occurrence of a ReDoS Imagine that a website has a form that accepts user input and uses a regex to validate the input. The regex is designed to only allow alphanumeric characters in the input, so it looks like this: /^[a-zA-Z0-9]+$/. An attacker could potentially craft a string of input that consists of

Application performance optimization using Webpack

Webpack provides support to improve the application performance. This article explains how we can achieve optimized application performance.

Speeding up Rails 7's Controller Actions using ActiveRecord's #load_async

Most of the time in a web application, a single API request consists of multiple database queries. For example: class DashboardsController < ApplicationController def dashboard @users = User.some_complex_scope.load_async @products = Product.some_complex_scope.load_async @library_files = LibraryFile.some_complex_scope.load_async end end Quoting snippet from load_async PR description from rails repository. The queries are executed synchronously, which mostly isn’t a huge concern. But, as the database grows larger in size, the response time of requests is getting longer. A significant part of the query time is often just I/O waits.

How to add Elastic APM Support in Dotnet Framework

These days for every web application, there has always been the need to monitor application performance, but not always do it well. Similar is the case with the .NET application, but then we found Elastic APM, which is the best solution over this need. Here in this article, we will look at how to use Elastic APM in any .NET application. What is Elastic APM? Elastic APM is an application performance monitoring system. It's a real-time monitoring tool for applications. With Elastic APM, we can determine information on requests, responses, database queries, and external HTTP requests. Current version available for

Server-Side Rendering : Summarized

In Web Development, one of the core decisions developers have to make is to decide where to implement rendering in their application. The two most common rendering techniques are Client-Side Rendering: renders web page on the browser Server-Side Rendering: renders web page on the server Let's understand both the techniques in detail. Server Side Rendering VS Client Side Rendering: Before understanding both the techniques, let's get familiar with the following two important Performance Metrics: First Contentful Paint (FCP): This metric measures the time from when the page starts loading to the time when any part of the page's content is

Scaling Enterprise SaaS Platform with Microservices

Spoiler Alert: This article is not about Microservices architecture or how microservices works. In this article, I will share what we have learned in scaling one of the large SaaS platform, our ongoing improvements and how Microservices architecture is playing a key role in scaling this SaaS platform. This SaaS Platform has experienced tremendous growth in the past 18 months. It has now become one of the leading CRMs in North America. Everyone’s definition of “scale” and “growth” can differ based on specific numbers or metric a company is targeting i.e. revenue, user base, or others. We are

Performance Optimisations on a Rails App

Method Missing Method Missing is one of the concepts of metaprogramming ruby. Although metaprogramming is very powerful it too has some shortcomings especially speed. A normal method is comparatively 1.5x times faster than a missing method. One of our users complained about our calendar page being very slow - on inspecting we found request was taking more than 30 seconds for loading the month view of the calendar and eventually request timed out. The user had lots of activities on that calendar - 2000+. On further inspection, we found our DB query was quite fast but each activity was

Adding new column with default value to high volume database table

Almost all Ruby on Rails developers might come across scenario where they need to add a new column with a default value to one of the database tables. Most of us (including me) would write following migration statement - add_column :table_name, :column_name, :boolean, default: false This is a good practice but would cause downtime if the table has large number of records. It took 3 secs when I ran the migration for a table having 50k records. -- add_column(:table_name, :column_name, :boolean, {:default=>false}) -> 3.3695s 3 secs is a long

Better performance with Index type `varchar_pattern_ops` operator_class in Rails

Rails has provision to provide order of indexing on a column for better performance of like queries. The varchar_pattern_ops improves the performance of like queries by 4 times i.e 4x. For example, lets have this like query on name column (that has sequential index.) Select * from users where name like 'John%' We might have added a regular Rails index in migration for this name column as add_index :users, :name - This will generate a sequential index. The same can be made 4 times faster using btree index by adding xxx_pattern_ops options add_index

Benchmarking in Rails console - Know performance of a code snippet

Lets say we need to benchmark and evaluate the performance of code snippet. This is how we can easily do on Rails console using "Benchmark.ms" require 'benchmark' 1.9.3-p392 :001 > Benchmark.measure do 1.9.3-p392 :002 > "john mark McMillan".split(" ").collect{|word|word[0] = word[0].upcase; word}.join(" ") 1.9.3-p392 :003?> end => #<Benchmark::Tms:0x00007ff6cd8face8 @label="", @real=1.600012183189392e-05, @cstime=0.0, @cutime=0.0, @stime=2.9999999999960614e-06, @utime=1.8999999999991246e-05, @total=2.1999999999987307e-05 1.9.3-p392 :004 > Benchmark.