Best database for a social network if starting from scratch today?
Database Gurus, I’d love your advice! I’m building a new social network that has a combination of a feed/wall and a Discord-style chat. What database would you recommend and why? Eg. SQL, noSQL or a combination of the two and what types eg. MySQL, DynamoDB etc
45 Replies
I definitely believe that, if you are not sure whether to choose SQL or NoSQL, then do not choose NoSQL....
Surely we need both though to handle excessive reads and writes to the database?
Depends a lot on the data
You can parse sql data into nosql, but the opposite is very hard
And you can use both if you want to
The noSQL would be mostly for “hot” data when synchronously chatting back an forth, when users need to read and write quickly. Did you have a preference on what type of SQL and noSQL database?
I would say either SQL or maybe even a graph databases because a social network of any kind is going to have a lot of complex relations which is definitely not a good use case for a NoSQL db.
Redis, because it's fast, especially if you're building a chat app
Thanks @VictorTimi, why would you choose Redis over DynamoDB?
Thanks @OwenWexler. Why would you use a graph database instead of REST API or tRPC?
Graph database doesn’t replace an apps api it’s just another way of storing and organizing data
maybe they are mistaking it for graphql?
Probably but I'm just trying to clear it up
Apologies @keef @Sybatron is right, I meant to say GraphQL vs REST API.
Yeah dw about it 😄 I was just making sure you were aware
but graphql benefits are usually for fetching exactly what you need vs over fetching with REST, It does well in a app that has a different language as the API being consumed
as a simpler rule
I got confused because @Own3r3k mentioned graph databases earlier and I got my posts mixed up.
use plain sql and later changes if you need
yep I was trying to figure out how to say that
moving from sql is easier than moving to
This is a very broad question and it can have lots of answer but it requires things like knowing how many users use the app
the scale is very important
If your project takes off you can pay some experts to help you move it to a more scalable system
if you are doing a poc, sql is just fine
sql with correct indexes is amazing
We are starting out with MSSQL and DynamoDb with REST API. I just wanted to make sure that’s the best approach and we’re not going to run into issues. The app is being coded in Xamarin.
dynamo is a tricky database
do you guys know the data access pattern?
like, really really coordinated already
I’m more involved with the UI/UX and concept of the app. My developer handles the code and he’s used DynamoDB before and he’s comfortable with it, plus he thinks it’ll be easier and cheaper to find additional developers for MSSQL and DynamoDB because they’re older and more established platforms.
He also doesn’t see the point of graphQL if you setup the REST API’s properly. I just want to get a better understanding of what’s out there and avoid any big issues as we scale. My background is more in IT and cloud computing infrastructure.
if the plan is to use graphql just as a typesafe api
its just weird to use it
if you really plan to use it like a graph, the main usage for facebook (lol), then its an amazing tool
SST
YouTube
How are my GraphQL APIs so fast?
We go over Pothos in depth and show off some useful patterns to serve efficient GraphQL queries.
Final repo: https://github.com/serverless-stack/sst-weekly-repos/tree/main/2022-08-02-practical-graphql-with-pothos
like this
The plan is to have functionality like Discord, but also have a social “wall” like Instagram and run it over the Matrix.org protocol. Thanks for the video, I’ll check it out 😀
Would would be fine starting off with an SQL database and then moving to a graph database as the app becomes more complex or are we better off starting out with a graph database. Would we be fine just using an SQL database with GraphQL?
just as a example
you can use a sql database to hold the main data
and some fast read database, like dynamo, to keep view data
so you don't have to calculate stuff on requests
Also, if we were going to use a graph database, which would you recommend? Neo4j, MemGraph, NebulaGraph, AllegroGraph, Redis, Cassandra with DataStax, AWS Neptune, GraphDb, ScyllaDB with JanusGraph etc
Exponent
YouTube
Design Reddit: System Design Mock Interview
Don't leave your career to chance. Sign up for Exponent's system design interview course today: https://bit.ly/36Z09jp
In this interview, Kevin (fmr Google, Tesla Engineer) answers a system design interview question of designing Reddit, commonly asked in engineering management, software engineering and technical program management (TPM) intervi...
also something like this is a nice resource
I read that Discord recently moved from Cassandra to ScyllaDB, which I found interesting. They made a tonne of customisation though…
cassandra is not a graph database
cassandra is a kkv
a option to dynamodb
using just sql is fine to start with
later migrate data to "better" database alternatives
as the data is normalized, you can easily aggregate it
but they have trillion messages already that's why they needed the change 😅
Great! That’s very reassuring. I’m picturing this nightmare scenario where we pick one architecture and then we’re stuck with it… 😅
same with cassandra they just hit performance dead end
cassandra is written in java
and jvm is a resource hog
plus cassandra is a pain to deal with
So what would you recommend as your ideal SQL and noSQL combo for a social network?
mysql (planetscale) is amazing
scylla is amazing for something like discord
if you plan on adding search, then something like elasticsearch or meilisearch would be good too
scylla and dynamo can share a similar role at that, its more of preference and experience
Why would you recommend MySQL on PlanetScale vs on other provider and why MySQL over MSSQL? Is it just licensing and hosting costs or is MySQL a better database for this use case?
planetscale pricing is amazing
you can per usage
they use same tech that youtube is using (vitess)
Yeah it looks really good. We’re abusing AWS for all their free startup credits at the moment and then may move to PlanetScale once they dry up. Kind of stuck if we stick with DynamoDB though…
if dynamo is not the main database
its fine to move away
you just would have to "reseed" the data in another nosql
Awesome, thank you 🙏