Link to home
Start Free TrialLog in
Avatar of Zeke Rich
Zeke RichFlag for United States of America

asked on

How to Build a real Facebook Clone

Hi, I was wondering how I could build a Facebook Clone on a budget.

I am more specifically asking how can I build a CMS with open sockets on a shoe string budget. Is there any hosting that supports open sockets? Is there any open sockets framework that would work well for this?
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Avatar of Zeke Rich

ASKER

@DavidJohnson

Yes I guess I meant websockets, although im not sure if FB is really using websockets or just faking it with Long Polling.  However I am interested to know if its possible to to build such a beast or any other type of Socket like Socket.io on a hosting service.  

I was able to build a open socket chat room on a small linux server i built at home but its not scaleable at all. Its also not secure in any manner and I dont have the experience to run a server of my own. I would like to attempt to build on websockets but I dont know where to begin publishing it for consumer use. 
Zeke, you have a couple of ideas here. One is how to make your own facebook type of thing and the other is using websockets.  Those are really different items and one is just a small cog in the wheel to the other.

First of all, there are open source projects for creating a community already and for something like this, why reinvent the wheel?
https://www.opensource-socialnetwork.org/ 
https://elgg.org/ 
https://www.humhub.com/en 

I think all you need is php and mysql and you are off and running.

If you were going to roll your own from scratch, I would stick with using azure or aws. If you want to  use sockets, it is there https://azure.microsoft.com/en-us/blog/introduction-to-websockets-on-windows-azure-web-sites/  Push notifications => yes, https://docs.aws.amazon.com/sns/latest/dg/sns-mobile-application-as-subscriber.html, infrastructure that can start out small and grow => yes, free tier for a year => yes
Oh, for the cms, I think you are talking about a headless cms https://headlesscms.org/  where it is a complete system like wordpress.
Real Facebook != Shoestring Budget

Fairly easy to build Facebook functionality - This will require a large budget + long timeline.

To build Facebook functionality - Suitable for 1,000,000s+ simultaneous users requires large budge/timeline, also some very good developers experienced in designing this type of software.

You can get an idea of a starting point by setting up WordPress + BuddyPress or BuddyBoss or exploring one of the 16M results returned from these searches...

Search - wordpress facebook clone - general search for free + paid code.

Search - site:github.com wordpress facebook clone - specifically free code as a starting point.
Hey guys, if you dont know what websockets is or long polling. Please do not respond to this post. Wordpress, buddy press, or some cheap generic FB template made with photoshop and PHP without long polling is not what I am looking for.

I already explained that I am developing in node.js with socket.io currently and that I wish to develop a REAL FB clone with either long poling or preferably websockets.  

Is there anyone who actually has experience working with long polling or websockets who can help me?  Im not looking to hear from FB template designers. I want real FB updates in real time. That is the only thing that separates FB from the rest of the garbage out there.

This is a question simply about the core functionality of FB (long polling), not about their millions of API's or about how they scale their servers. 


I am looking for a host that can support this type of application, web sockets, mqtt, node.js etc:

https://stackoverflow.com/questions/1427419/can-i-create-a-socket-application-on-a-hosting-service 

I already built a tiny server with websockets, its working well, using Raspian Buster Linux, but it can only host maybe a few hundred people. It only has a Arm Cortex Quad Core Processor. So yes it can be done on a $30 server. Yes it can be done on a budget. But now i need to scale up... and I cant. 
What you asked for initially was, "I was wondering how I could build a Facebook Clone on a budget. "  Please realize that is where the type of comments you received came from as well as the topics you chose.  From your last comments it sounds like your real interest is in how to scale two way communications.  This is why I said, "you have a couple of ideas here. One is how to make your own facebook type of thing and the other is using websockets.  Those are really different items and one is just a small cog in the wheel to the other. "

I suggest just deleting this question and starting a new one.  In your new question, be more succinct and focus on the back end server. What is your real question?  Is it the server requirements for an estimated amount of users?  What is the estimated usage you expect in year 1 and beyond?  You mentioned security. You also asked which type of host can support sockets. You need to start with the specs. Then go from there.  David who has commented here is well versed in scaling linux servers.  Given the right question, he can be very helpful for you and there are other very good linux experts here. I am windows myself. I can't be much help for you.

So yes it can be done on a $30 server. Yes it can be done on a budget. But now i need to scale up... and I cant.  

Again, confusing what you are asking for.  You seem to already know it can be done. This type of service requires hardware. The more hardware you throw at it, the more you can scale.. But that is a low budget for large scale. Of course, large is relative. This is where details will help. What are your expectations as far as concurrent connections?  

@Scott Fell  I am not asking about load balancing or scaling. I do not have a single user. I am asking how to build a Facebook clone that uses websockets as a startup. Maybe you are not aware that Facebook uses websockets type polling? It is the only cms that uses websockets that i know of. Do you know of any others? This is the only reason people use FB is because of the websockets real time updates. I dont think you understand what im taking about. Facebook pages update similarly to using AJAX it is called websockets. Why would I want to build a clone that does not have this functionality of websockets updates to each post?  Can you show me a clone that can update posts without refreshing the page? Do you know how to update each post without refreshing the page? I dont want to refresh the page all day long. This is what websockets are for.  You keep telling me that FB and Websockets are two different things. I honestly dont think you have a clue what you are talking about.

Here is an example of websockets. You can see the post is updating without refreshing the page...  This is how Facebook works. Do you understand now? ....




User generated image


I already built this and now im trying to host this on a public server. But I can not find a host that will allow me to use open sockets. I am trying to avoid purchasing my own server and allocating a space at a data center.

Every single post will need to have its own socket. When I create a timeline of these socket posts there will be many sockets involved. Each post will need to have its own socket. Linux itself allows billions of open sockets.

I honestly dont think you get it. 
ASKER CERTIFIED SOLUTION
Avatar of Zeke Rich
Zeke Rich
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Aside...

Keep in mind... There's a reason Facebook abandoned Websockets, switching to long polling instead.

Before you head down the Websockets Rabbit Hole, best to research why Facebook made the switch.
From my research the Reason FB went with long polling is because at the time not all browsers supported websockets nor were html5 compliant and websockets was and still is next-generation bidirectional communication technology. Since FB already built it this way and its working there is no point in fixing it. So they continue to use long polling. 
Zeke, I have been doing this for a while. It's common that when people get a little knowledge about something there is the stage of knowing just enough to be dangerous. But when you don't realize that, it is called Dunning–Kruger effect.

We are trying to assist you, there is no reason to cast your frustration at us.  

90% of your answer can be achieved just in asking the right question. Of course, that is not always easy when you are not sure of the subject matter. That is where making sure the person answering understands when you meant and not what you said.  It is also common that the person answering your question may read some keywords and focus on the wrong thing.  This is where it takes both parties, the asker and the person being asked to fully be in sync.  

What are your expectations as far as concurrent connections? 
I have asked some specific questions of you such as this to get a better understanding of your requirements.

I see your question  has been edited since the start, and currently it is, "I am more specifically asking how can I build a CMS with open sockets on a shoe string budget. Is there any hosting that supports open sockets?  " and I answered that here 
" If you want to  use sockets, it is there  https://azure.microsoft.com/en-us/blog/introduction-to-websockets-on-windows-azure-web-sites/  Push notifications => yes,  https://docs.aws.amazon.com/sns/latest/dg/sns-mobile-application-as-subscriber.html, infrastructure that can start out small and grow => yes, free tier for a year => yes"

"...on a shoe string budget. "
Both of those options have a free tier.

You may not realize it, but there are multiple parts to your question.  Once is how to code and the other is the server end.  You have found socket.io, my assumption would be you already knew about that. The coding portion is going to be easier and you will see examples on the git hub pages. The server side of things is where it gets more complex because as you found out shared hosts do not typically support this.

You keep telling me that FB and Websockets are two different things. I honestly dont think you have a clue what you are talking about.

Well, if you assume Facebook is only websockets, then you would be correct. If you understand that what makes facebook, facebook is:

  •  A group of websites and native applications consisting of
    • Front end
      • HTML
      • CSS
      • Javascript
    • Back end
      • Server side code
      • Database
    • Data centers around the world
    • Developer API's
  • Family
  • Friends
  • Communities
  • Events
  • Shopping
  • Businesses
  • Marketing

Then you would be wrong.  It is all a matter of perspective. While you may be focusing on one very specific item and to you facebook is just sockets, to somebody else it is something different.

Good luck on your project.
Facebook clone.
Though, while we were reverse engineering Facebook’s Messenger to add PGP to it I noticed that they utilize long polling to fetch messages.  
https://blog.stanko.io/do-you-really-need-websockets-343aed40aa9b 
Since FB doesn't use web sockets and uses long polling. Why insist on Web Sockets.

You previously stated 
This is the only reason people use FB is because of the websockets real time updates

This is a fallacious  argument. FB Messaging is only one very small part of FB

                 WebSockets   Server Sent Events   Long Polling
# of Parallel      1024      ~6 per server      ~6 per server
Connections


Load Balance/   Complicated   Easy         Easy
Proxying      Non Standard   Standard      Standard


Browser Support   Yes (90%)   No (84%)      Yes (100%)


Dropped Client   Yes      NO         No
Detection


Reconnection      No      Yes         No
Handling

Open in new window


I see your question  has been edited since the start, and currently it is, "I am more specifically asking how can I build a CMS with open sockets on a shoe string budget.

Thats is really funny, it says i edited my original question today. I havent even been online in 3 days. And NO I have not edited a single thing. Nice try.

This conversation had gone way off topic. just close it.