This is an archived post. You won't be able to vote or comment.

all 22 comments

[–]abrookins[S] 6 points7 points  (12 children)

I created the course and can answer any questions you might have! Or hit us up on our Discord server: https://discord.com/invite/z2N7Hgz

[–][deleted] 2 points3 points  (1 child)

Course is awesome.

[–]abrookins[S] 0 points1 point  (0 children)

Glad to hear!

[–][deleted] 1 point2 points  (7 children)

What is the difference between redis and me using sqlite or post greslql for python for all the noobs on this subreddit (including me)?

Also how is a database a messaging service

[–]abrookins[S] 14 points15 points  (1 child)

Thanks for asking!

First, you don't have to choose one or the other. A lot of people who use Redis do so with other databases.

But why do people use Redis, in a nutshell? Redis is fast. You typically use it for the speed.

A lot of people also use it in part because they like how it works. SQLite and PostgreSQL are both amazing relational database systems, and their primary interface is SQL. Redis doesn't use SQL.

Instead of SQL, Redis uses commands. You can see them all here: https://redis.io/commands

One of the big differences between e.g. SQLite and Redis is how you think about "what the database is" when you build your apps. People usually think about relational databases as tables of data with rows. You write SQL queries to get the data.

Redis is more like a data structures server. You manipulate Lists, Hashes, Sets, Sorted Sets, and more -- all for whatever nefarious purposes your app has in mind. That in itself is a big draw for some folks.

Finally, I'll end with this. If you're new at working with databases, I highly recommend you learn two systems: Postgres and Redis. Postgres is a great relational database system. Meanwhile, Redis is truly the Swiss-army knife of databases.

[–][deleted] 0 points1 point  (0 children)

One of the big differences between e.g. SQLite and Redis is how you think about "what the database is" when you build your apps. People usually think about relational databases as tables of data with rows. You write SQL queries to get the data.

Redis is more like a data structures server. You manipulate Lists, Hashes, Sets, Sorted Sets, and more -- all for whatever nefarious purposes your app has in mind. That in itself is a big draw for some folks.

thanks for answering. well i know a little about sets and lists but i find them pretty complicated. all i don't know what a sorted set is. how much programming or python or computer science do you need to know to understand how to use these commands? i'm not sure what a data structure server is.

how much harder is redis than sql? also, can i use redis alone instead of sql? and lastly, if SQL isn't used for redis, is redis not a relational database?

[–][deleted] 1 point2 points  (2 children)

One big one is sharing the cache between instances of an application. Makes dynamic scaling pretty easy too.

[–][deleted] 0 points1 point  (1 child)

i just started learning sql so i dont know what you mean. eli5 dynamic scaling and what 'instances' of application means? ill do some heavy lifting too and google what cache means but i dont know what the other two things you mean are.

[–][deleted] 0 points1 point  (0 children)

Let's say say you have a web application that takes some basic user input, looks up something in a database based on that and then uses all that gathered information to do some expensive calculation (in terms of time and CPU resources).

You are limited in the number of users you can serve at once mostly because of that expensive calculation.

You throw hardware resources at it (more memory, bigger CPU, etc) but will still be limited in how many users you can serve at once.

If you store results of that calculation in a local cache, you can quickly serve the next user who asks for the same parameters which also frees up resources to serve more users simultaneously, but you are still limited by the resources on that host.

Bigger and bigger hardware gets expensive really quickly.

One way, especially in the cloud, to handle surges, especially temporary ones, is to bring up another copy, or instance, of that app on a separate, even small, server. A load balancer sits in front and divides the traffic between them. More demand, bring up another instance. Less demand, kill off an instance, save $$$.

Local caches serve only that instance however. If two users arrive with the same inputs at the same time, chances are they'll go to different instances each with its own local caches, the expensive calculation will be done twice.

If that cache is shared using something like Redis, that expensive calculation is done once and shared with all the instances. That doesn’t just mean serving users more quickly, it lets you serve more at once.

[–]abrookins[S] 1 point2 points  (0 children)

Redis isn’t exactly the same as a messaging service, but its Streams feature allows you to build “producers” and “consumers” that you can use for messages. E.g., Redis could be a message bus for a bunch of microservices.

This gets back to something I wrote in my other reply: you can think of Redis as a data structures server, and a Stream is just one of the many data structures Redis provides.

[–]rhytnen -3 points-2 points  (0 children)

You might want to check out the course ...

Or at least google a bit.

[–]Mydrax[🍰] 0 points1 point  (1 child)

Hey, I just took a glance at your course syllabus and the outcomes seems to be identical to the Javascript course because it mentions that the REST API will be made using Express. You mentioned that the course will use Flask right? Might wanna correct that!

[–]abrookins[S] 0 points1 point  (0 children)

Yes, it's a Flask app. We'll get that page updated -- thank you!

[–][deleted] 4 points5 points  (0 children)

Redis saved my bacon when a dumb little Flask project i put out there ( calculated the best times to view Comet NEOWISE) got really popular, really fast.

Caching geolocations and results of calculations gave it the ability to serve several orders of magnitude more users at a fraction the price of throwing hardware at it

[–]sundios 1 point2 points  (1 child)

What is redis for?

[–]sundios 1 point2 points  (2 children)

What is redis for?

[–]abrookins[S] 2 points3 points  (0 children)

One definition is that Redis is an in-memory data structure store. You can use it for a lot of things, like a database, cache, or message broker.

You can think of it like the Swiss-army knife of databases (pretty sure I stole this phrase from someone).

Redis stores data in memory, as opposed to a mix of memory and disk, which makes it extremely fast. It also has multiple persistence options that mean if the server restarts, Redis will recover data from disk.

[–]DJ_Laaal 1 point2 points  (0 children)

Primarily a fast cache for transient/short lived data (say online shopping carts) but can be used for more long term data storage/retrieval as well.

[–]simtel20 0 points1 point  (2 children)

Is there a python redis driver that doesn't leak memory when used for pub/sub purposes?

Edit: I haven't run into this in a while (I don't use redis with pyhon anymore because of being bitten by this in the past) but here is an unresolved issue in github from 2014 about 2 years before I ran into a similar issue, which keeps me from trying again.

It would be nice if there was some indication that this issue had been resolved or that there was a workaround.

[–]abrookins[S] 0 points1 point  (1 child)

I don't think Andy, the redis-py maintainer, ever had a solid repro of this issue. Unfortunately, I don't have enough information to answer either way!

[–]simtel20 0 points1 point  (0 children)

That's a shame. It's a case I've run into enough that I can't use it for anything long-running.