Redis is way more than just a cache system - it's a powerful distributed key-value in-memory database with rich features. Let me break down why Redis is awesome and what you can actually build with it.
Keep Reading🧵
2/12 Redis stores everything in memory, making it blazing fast compared to traditional databases like MySQL that need disk reads.
But don't worry - Redis still persists your data using AOL and RDB, so you won't lose anything if you restart.
3/12 Redis Lists are perfect for building queues, stacks, and temporary storage.
You can implement job queues, undo/redo functionality, recent activity feeds, and data buffers. Think Spotify's "Add to Queue" or Amazon's "Recently Viewed Items"
Here's a thread with fundamental tips and techniques to optimize your database queries.
🧵 Keep Reading
2/ First tip: Use EXPLAIN to identify inefficient queries.
Watch out for 'ALL' access type. It means full table scan. MySQL scans the entire table. It's like a for loop that iterates through each row,
The 'Index' access type isn't great either, as it reads the whole BTREE index.
3/ 'Range' access type is good, sinbce MySQL is able to identify a range of rows fromn an index. But check if 'Using index' appears in Extra column. If not, you're doing unnecessary I/O operations.
🔥 Here are some of the most basic monitoring techniques you can start using immediately:
- Spatie laravel-health
- Error tracking
- Syntethic checks
It takes ~30 minutes to set up these.
🧵 Keep Reading
Health checks with laravel-health
The package can check:
- CPU load
- Disk space utilization
- Database connectivity
- Redis
- And even query speed
The example contains pre-built checks. For instance, it notifies you if the average CPU load is higher than 2.5 in the last 5 minutes or 2 in the previous 15 minutes.
It also notifies you if the used disk space is more than 70%
🔥 Most applications need to export and import large amounts of data.
It is very easy to:
- Waste lots of memory
- Perform hundreds or thousands of unnecessary DB queries
You can avoid them by learning some pretty simple techniques.
🧵 Keep Reading
1/
When it comes to working with larger datasets one of the best you can apply to any problem is chunking. Divide the dataset into smaller chunks and process them. It comes in many different forms.
2/ Let's start with a simple CSV or XLS export since it's a common feature in many applications. laravel-excel is a pretty good package that you can use.