• Latest
AWS SQS in a Large Scale Application

AWS SQS in a Large Scale Application

March 10, 2023
BodyGuardz launches Apex ceramic iPhone screen protector, claims ‘virtually unbreakable’

BodyGuardz launches Apex ceramic iPhone screen protector, claims ‘virtually unbreakable’

May 30, 2023
Pokémon Scarlet & Violet: All Transfer-Only Pokémon Available Via HOME

Pokémon Scarlet & Violet: All Transfer-Only Pokémon Available Via HOME

May 30, 2023
Apple promoting WWDC23 Swift Student Challenge winners, award includes AirPods Pro and special pin pack

Apple promoting WWDC23 Swift Student Challenge winners, award includes AirPods Pro and special pin pack

May 30, 2023
Xbox Games with Gold June lineup announced

Xbox Games with Gold June lineup announced

May 30, 2023
Destiny Made More Than $160 Million Through Microtransactions In Under Two Years

Destiny Made More Than $160 Million Through Microtransactions In Under Two Years

May 30, 2023
Brilliant RPG Chained Echoes Is Getting A New Game + Mode Very Soon

Brilliant RPG Chained Echoes Is Getting A New Game + Mode Very Soon

May 30, 2023

Wrestling RPG Adventure Game ‘WrestleQuest’ Is Coming to Mobile Through Netflix This August Alongside PC and Consoles – TouchArcade

May 30, 2023
Samsung launches self-repair program in South Korea

Samsung launches self-repair program in South Korea

May 30, 2023
Reality Pro demos likely to need a scarce Apple Store appointment

Reality Pro demos likely to need a scarce Apple Store appointment

May 30, 2023
Laravel vs. Django: A Head-to-Head Comparison

Laravel vs. Django: A Head-to-Head Comparison

May 30, 2023
How to see the Apple WWDC AR Easter egg

How to see the Apple WWDC AR Easter egg

May 30, 2023
Xbox Game Pass to add eight more games in June

Xbox Game Pass to add eight more games in June

May 30, 2023
Advertise with us
Tuesday, May 30, 2023
Bookmarks
  • Login
  • Register
GetUpdated
  • Game Updates
  • Mobile Gaming
  • Playstation News
  • Xbox News
  • Switch News
  • MMORPG
  • Game News
  • IGN
  • Retro Gaming
  • Tech News
  • Apple Updates
  • Jailbreak News
  • Mobile News
  • Software Development
  • Photography
  • Contact
No Result
View All Result
GetUpdated
No Result
View All Result
GetUpdated
No Result
View All Result
ADVERTISEMENT

AWS SQS in a Large Scale Application

March 10, 2023
in Software Development
Reading Time:6 mins read
0 0
0
Share on FacebookShare on WhatsAppShare on Twitter


In today’s article, I’m going to show you how we use AWS SQS in our Laravel application and how it helps us manage 1.6 billion operations each month.

In the image below, you can see our typical bill for a month of AWS SQS usage:AWS SQS

Before entering into the details of our system design, I would introduce the SQS technology, why you should consider a messaging system, and how to compare it with similar services.

What Is AWS SQS?

Amazon Simple Queue Service is a fully managed messages queueing system to enable communication between distributed software components or microservices.

Decoupling some parts of your system allows you to run and fail your software components independently. It also allows you to build easily scalable applications.

Message queues act as intermediaries:

Intermediaries

What Is a Message?

This is an important question I want to answer to help developers who are approaching this technology for the first time.

Every message queuing system accepts a text as the content of a message. The most common way to make different systems exchange structured data is to use JSON objects.

JSON can be easily serialized as text when pushing a new message onto the queue and deserialized when it is consumed on the other side of the system.

The Laravel Way

Laravel implements its own format when exchanging messages with queue systems. Here is an example:

The Laravel Way

The JSON is automatically created by the internal queue system of the framework when you dispatch a job. It is somewhat hidden from the eyes of the developer.

The JSON message contains all data needed by Laravel to understand what job class should be executed and under what conditions (attempts, maxTries, etc.).

If your application doesn’t have a prepackaged solution like the one provided by Laravel, you can define your own format. The goal is to provide the consumer of the queue with all information to process the desired task.

How To Consume Messages from the Queue

You have to implement a system that continuously polls the queue waiting for a message to arrive.

Laravel provides a built-in “worker” that you can run with a simple command:

This command runs a background process that asks for new messages. When a message is retrieved, the worker can run the job class included in the message.

You can see this process in the IlluminateQueueWorker.php class:

while (true) {
	// Before reserving any jobs, we will make sure this queue is not paused and
	// if it is we will just pause this worker for a given amount of time and
	// make sure we do not need to kill this worker process off completely.
	if (! $this->daemonShouldRun($options, $connectionName, $queue)) {
		$status = $this->pauseWorker($options, $lastRestart);

		if (! is_null($status)) {
			return $this->stop($status, $options);
		}

		continue;
	}
	
	...

	// If the daemon should run (not in maintenance mode, etc.), then we can run
	// fire off this job for processing. Otherwise, we will need to sleep the
	// worker so no more jobs are processed until they should be processed.
	if ($job) {
		$jobsProcessed++;

		$this->runJob($job, $connectionName, $options);

		if ($options->rest > 0) {
			$this->sleep($options->rest);
		}
	} else {
		$this->sleep($options->sleep);
	}
	
	...
}

Why Should You Use AWS SQS?

Since my product is a developer tool, I discuss with other fellow developers almost every week about the internal design of their software. 

In most of the applications I’ve had the opportunity to analyze, a messaging system was introduced to enable asynchronous task execution. 

The same is for Inspector.

I think this is the most common use case for messaging systems today. Microservices or large distributed software, in general, are very niche use cases. Probably belonging more to enterprise environments.

What Is an Asynchronous Task?

Imagine your product offers the ability to import account information by uploading large files. The user picks the file from the local PC and clicks “Import.”

This operation can take a while to be completed. You have to open the file, read each line, convert it into the appropriate format, and store this information in your system.

It could be impossible to handle this process at the time of an HTTP request.

Thanks to a message queueing system, we can store the file on our servers and push a message to the “import” queue with the path where the file is. 

The next step is to make a background system that waits for these messages to handle the import process. Users don’t need to wait until the import is done. In the meantime, they can continue to use the product or leave it waiting to be notified when the import is completed:

Import

How Inspector Uses AWS SQS

The most important challenge of Inspector is to be able to process large amounts of traffic, also guaranteeing good performance.

The endpoint where Inspector receives data from the monitored applications handles about 10 million HTTP requests per day. With this volume, the problem is that these data packets can’t be processed on the fly. 

At the beginning of our adventure, we used a self-managed Redis as a message queueing system. But, with increasing volumes, we have preferred to rely on a managed service.

The strategy is to use AWS SQS to be able to push these tasks to a queue, which will be consumed by another separate system in the background (the processing pipeline):

Processing Pipeline

Ingestion nodes are implemented in Node.js. They are built as a very simple and extremely scalable script. The worker servers that consume the queue are, instead, a system component built on top of the Laravel framework.

We could have chosen any other technology to manage the message queue. At this stage of the company, SQS guarantees scalability without any complexity for us since it is a fully managed service.

Other solutions could also save us costs. We prefer to guarantee our customers that the platform works perfectly and avoid the risk of introducing weaknesses that could cause unexpected downtimes.

Conclusion

At this point, you should have a better idea of what AWS SQS is, how to use AWS SQS to scale your application, why you should use AWS SQS, and more. I hope you have taken away some valuable information from this article. If so, feel free to like and share.



Source link

ShareSendTweet
Previous Post

Hasan Minhaj Tackles the East Palestine Blame Game & McDonald's Cardi B Debacle | The Daily Show

Next Post

Paul Phoenix Rides Into Tekken 8

Related Posts

Laravel vs. Django: A Head-to-Head Comparison

May 30, 2023
0
0
Laravel vs. Django: A Head-to-Head Comparison
Software Development

Django and Laravel are two well-known web frameworks. Both have exceptional features, functionalities, and capacities to support and meet the...

Read more

Incident Response Guide – DZone

May 30, 2023
0
0
Incident Response Guide – DZone
Software Development

Site reliability engineering (SRE) is a critical discipline that focuses on ensuring modern systems and applications' continuous availability and performance....

Read more
Next Post
Paul Phoenix Rides Into Tekken 8

Paul Phoenix Rides Into Tekken 8

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2021 GetUpdated – MW.

  • About
  • Advertise
  • Privacy & Policy
  • Terms & Conditions
  • Contact

No Result
View All Result
  • Game Updates
  • Mobile Gaming
  • Playstation News
  • Xbox News
  • Switch News
  • MMORPG
  • Game News
  • IGN
  • Retro Gaming
  • Tech News
  • Apple Updates
  • Jailbreak News
  • Mobile News
  • Software Development
  • Photography
  • Contact

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?