Public post federation
The lack of public post federation in Diaspora is IMHO a make or break feature. The whole network is a little broken as small pods are cut of most of the posts on the network due to the way current federation works.
Here is my proposal for solving this issue, please see wiki post here.
It is not a comprehensive solution that can just be implemented now. It is a high level suggestion for going forward with talking about such a feature.
@loelousertranslato having many would mean that if a relay server is down, the posts still federate. After all these would be user hosted services, not commercial grady with 99,99% uptime guarantee.
If a pod cannot contact a relay it would just use another.
Also I think pods could easily check the origin of the post easily just by asking the originating pod for the hash and compare it to the one coming from the relay - to stop relays generating posts. Will add this to the proposal.
At first I was thinking that the central hub could be the relay…
If I understand it well the central hub server has to be on but not all the time : if it shut down for a few hours it would just delay the new tags and pods that are taken into account in the list… but the federation and sending of posts would still be ok because of the relay servers.
Yeah that is one part of the idea of separating the functionality of a central hub and relays.
Couldn’t the central hub hosting the pod list with tags be in the pods themselves. With keeping track of the latest version of the list and pushing it to all the connected pods (connected because users would have added a user/seed from them in an aspect) if their list is older and if the admin has authorized the kind of federation…
This way all pods participating to this should with high probability (?) and rapidly be interconnected.
This way the list of pods and followed tags should be repeated in each pods so that if some pods are shut down the system would still work fine…
Well IMHO we need to have some kind of central hub at some point. We already have a central hub called diasporafoundation.org for the project. We also have pod lists like podupti.me. Having an official central hub that would receive data from the pods themselves would have lots of benefits. Syncing everything everywhere is problematic. For example some podmin sets up a new pod - where would that pod send the subscription list to? All the pods? How, where would it get even one pod address?
The central hub could also be used to finally gather statistics from the network (opt in of course). For example pods could report their amount of local users and post counts and these statistics could be reported on the hub to see where the network is going.
I guess that a new pod would have to connect to any big pods around to be part of the public post federation. But well yes it has to have the info of where to find another pods first (podupti, web search engine…).
having the list in pods with close to close spread of last version of the list is not exclusive to having a central hub that can be implemented first.
-So the order for any pods would be : 1- use the hub if it is on. 2. If not, use its own list. 3. get the list from the hub if newer list in the hub. 4. send the list to any pods and the hub if its list is newer.
Well, I write “newer list” but I am not sure that a “newer list” is more complete. Not sure how to track for the most accurate and up to date list is. I am not familiar with syncing and all…
The central hub part feels just wrong, I need to think more about that part.
For the relay part, we can save the hash checking blabla, by not touching the Diaspora protocol message at all. It is signed by the author, thus there's no way for a relay to spam messages to the network, for the same reason it isn't possible right now. So we could just send messages like {"hashtags" :["#a", "#b", "c"], "diaspora_message": "xml in base64 blob ready to post to /receive/public"} to the relay server.
@jonnehass yeah I have no real grasp of the D* protocol so I didn't mention too much about the specifics in the proposal, just the idea of the relay.
To me the central hub makes sense for a reliable source of network data. I mean we don't decentralize the project page and the wiki either - the central hub isn't any different from those resources.
Still, I also believe tag federation across pods would be a good feature for Diaspora…
I have a different way to solve this problem. I'll try to get a page on the wiki this weekend.
OK, alternative proposal here: https://wiki.diasporafoundation.org/Tag_aggregation
Let me know if I should start a new Loomio proposal. I'm new at this.
What advantages does this method have over the scheme I proposed in this thread (it talks about tag federation about half-way down).
I'm not a coder at all, so this is just a concept rather than anything more detailed, but I hope it might help to improve D*'s federation, especially for new and one-user pods.
@goob My concern with that approach is that it's very inefficient (it looks like O(n2) for you computer science types where n is the number of pods; the amount of network traffic grows rapidly as the number of pods increases), and it implies that all pods are equally trustworthy sources of information about the podsphere.
Also it seems to me that your proposed solution would require a lot of new code to be developed, alongside new messaging semantics. This is based on a very quick analysis so I could be way off base here.
I'm trying for an incremental model that scales well with minimal new coding required. Also in my proposal tagged posts are federated in a very efficient model that scales linearly (O(n + m) where n is the number of posts and m is the number of pods).
Thanks for you reply. That sounds plausible (damnit!).
@Goob no damnit at all! I wouldn't have thought of using the pod to help locate other users or index other posts were it not for your proposal. There's probably a better idea out there than the one I proposed too; I just hope I can contribute something.
Great @bradkoehn ! And @goob all ideas are welcome - they all add to our ability to build the best solution.
There are many similarities regarding mine and Brad's idea - especially the part that relates to a central hub to store pod information. I really really am sure we need this, for many reasons. I'll put something in the wiki and separate this into it's own place since it is kinda separate though required by the public post federation/aggregation. Once we have a spec we'll just need to vote since I know some community members don't like this idea even if it is totally opt in :P
As for the idea from Brad, I'm quite sure it would do the job and would be happy if either idea was implemented. Initially I was questioning the idea of pull instead of push, but I guess the pubsubhubbub takes care of that problem (even though then we do rely on those external services, the default diaspora uses is from google).
I do think though that my relay server idea is lighter because there is no need to save posts. It also handles redundancy - pods are not tied to any particular aggregator and thus even if all but one of them are down the post will be delivered to all listeners.
Security I guess in both would be the same. Except I see some worry that an aggregator could be populated with non-authentic posts, and even if no pods accept the posts, some other source might do. Since the aggregator would have an open interface, it wouldn't take long for someone to build an app to show posts in the diaspora network going through the aggregator. In this situation it would be trivial to inject posts into the aggregator, unless the aggregator checks all of them. In the relay idea this is not a risk since the aggregator doesn't store posts.
Any other opinions on these ideas?
I don't know enough to talk about the technical point, but I know something: I'm strongly opposed to anything which would involve Google services (even if it's public data): we saw how they turned of Google reader, or decide suddently to make Google Maps API a paying service. I don't want to depend of a company for a feature critic like this one.
There are many P2P networks and routing protocols out there, In my opinion we should go this path.
What if every pod was a relay for it's own users' followed tags?
I’ll prefer the distributed path even if some seeds/pods would loose a bit of not federated info. (Not sure to understand how it would work out though). @macieklozinski : could you precise how it would work for tag federation ?
I'll try to do some deeper research on possible p2p solutions.
I'm not sure if it fits well with Diaspora's protocols, but I could suggest something like this:
- When user A shares with user B on another pod, user B's pod becomes "neighbor" of user A's pod.
- User B's pod "subscribes" to user A's pod for all tags that user B's pod users follow.
- Each pod keeps a list of it's neighbors and tags they subscribe.
- When user on a certain pod makes a public post, it's sent to all neighbors subscribed for tags present on this post.
- If a pod receives a public post from other pod and does not have this post in it's database, it passes it to all neighbors subscribing to tags present in this post, and saves post to database.
- If a received post is already present in database, nothing happens.
I think there's a big difference between having a central hub which contains information pertaining to the D* network but which is separate from the network itself (such as the project website, poduptime, etc), and a central hub which is an integral part of the D* network and receives/sends/stores data from that network, such as post data, which is what is being proposed here. With a central hub as an integral part of the network, the network would no longer be fully distributed.
If a central hub of any sort is actually needed in order for post/tag federation to work properly, I suggest it be restricted to holding meta-data, such as a list and IP addresses of pods or relay servers. This could be the same central hub which helped people to choose a pod to register at, as poduptime does at the moment.
It would then only be referred to when a new pod or relay server was brought online. The new pod would then call hub.diasporafoundation.org (for example), which would give it some pods/relay servers to contact from which it could pull post data. The actual transmitting of post data would be done by the pods/relay servers themselves, with no involvement from the central hub.
This is similar to one of the proposals I made in this discussion on adding pull to Diaspora's push model (the proposal concerning tags).
I'm not sure relay servers separate from the pods themselves would be needed; I think there is a way of making pods federate public data more effectively without using a separate network of relays, if they are connected correctly together.
Note that in the following, when I talk of connections/sharing between pods, I'm not talking about the normal connections between pods which exist, but a kind of meta-network to push public data around more effectively, of the kind Jason talks about in his proposal.
I would suggest using a kind of 'cell structure', in which each pod is connected directly with several other pods in the network, and through that structure build up a list of public posts and tagged posts data to pass on to other pods. This avoids the problem of scalability faced if 'every pod knows every pod'. If the relay connections between pods are made correctly, public data will be federated to every pod quickly, via indirect routes (Pod A shares it with the several pods to which it has direct connections; those pods share it with the pods with which they have direct connections; and so on). If there is redundancy built in to this network, it won't matter if several pods in this network are down; the data will get fed around to the whole network eventually in any case.
It might be that each pod needs to be connected only to two other pods in the network for this to work, like the classic Communist cell structure – as in the graphic below (not perfectly illustrated, but it gives you an idea):

I'm sure there is a way of coding into the D* software itself so that it builds a network of connections such that each time a new pod is brought into the network, the network recalibrates its connections so that this new pod is made a part of the sharing network, without reference to any external source such as relay servers or a central hub. Likewise each time a pod drops out. However, I would have no idea how to do this! I hope someone out there will do, and that my partly developed concept will spark ideas for practical solutions in their mind.
If a central hub is needed to help new pods get connected, I think we should have a mirror or two on other servers just in case the project site is down when a pod is brought online.
@goob , will read the rest of you long comment later, but you should maybe read my proposal too ;)
a central hub which is an integral part of the D* network and receives/sends/stores data from that network, such as post data, which is what is being proposed here.
I have proposed no such thing. This is the reason I stopped the whole vote for the central hub because not many people even understood my proposal.
My mistake. I did read you various proposals and wiki articles, but there’s been so much to read and digest that I got confused. I read that suggestion somewhere on one of the several threads on this/related topics, then while writing I got my wires crossed and thought it was you who had proposed it.
Just ignore the last seven words in that extract. The point stands, no matter who proposed it, or even if no one has proposed it yet!
OK read the whole post now. I think we are thinking on similar lines. However, as a software developer I always think of one of the golden rules of software design - making sure each component has one purpose and that only. Incorporating everything and the rest too is possible - hey we could make diaspora also serve files and incorporate an IRC server + maybe do some test automation services on top. But it's a bad idea. Diaspora server as it is now exists to provide the UI for the server. The federation stuff is actually being pushed out of the main component just so that diaspora will be more flexible. Why would we want to bundle up more non-UI related features then?
IMHO, the system to federate posts around should be decentralized, but it should also be it's own mini-network of volunteers. This is exactly what my relay servers proposal is about. :) A bunch of relays taking care of the public post handling in a decentralized way - and pods will not even have to decide which relay to use, giving total redundancy even if all except one relay is down.
I still feel many people misunderstood this which is why when I finish the statistics hub, I'll start working on a POC relay and see if I can provide the hooks on D* side (the more difficult part for myself, being ruby).
Also, as you said, we could federate the metadata for relays around totally without a central hub. Sure it's possible, but imho it's a bad idea. It adds nothing to decentralization and does not benefit anyone in any way except adding complexity. A simple list on the project site would do fine, since pods would only need to pull it in every so often to refresh their list.
Decentralization is a good thing and awesome - but it's not a magic word to use with everything and assume that it makes thing better.
Btw, my original proposal said storing the "wants tags" list on the central hub. This is not really necessary if such data is stored on the relays instead. It just would mean more posting of said lists around since all relays need to know asap or the pod will miss posts. Storing the list on the central hub would make for less bouncing off lists around - if the central hub is down it doesn't matter since relays have the latest list and will then refresh once the central hub is back up.
At no point in the proposal was I proposing that traffic stops when the central hub is down :)
Does anyone know what it is specifically in the code or structure of the Diaspora network which is causing public post federation to work unreliably?
If it is because Diaspora relies on push notifications to transmit data between pods, could this be solved by allowing a pod to send pull requests to other pods in the network for any data missed when it comes online after some downtime or after being overloaded and unable to receive communications from other pods, or after it is brought online to the network for the first time? I propose a potential solution to this under 'Non-communication' (the third point) in the discussion about adding pull to the push model for federation. While there are concerns about scalability for the other points (getting new pods fully connected and federating tags) in my post, hopefully enabling a pod to send a pull request to other pods when it comes online so it can pick up data (including public posts) it missed while it was offline would help federation of public posts at least in some circumstances where it currently fails.
If we could identify the various factors causing causing federation of public posts not to work properly in different circumstances, it would, I'm sure, be a big help in solving the problem.
@goob it's not that public post federation does not work properly, it's that it's not implemented at all. Currently posts just end up on various pods - there is no technical design to say that any public post should be available to any subscriber on any pod.
Personally I want to start prototyping the relay concept - I think once I have a working demo it might be liked ;)
OK, thanks. That definitely sounds like a design flaw!
By the way, @bradkoehn, I think it would be worth making your proposal here in Loomio, as proposals on the wiki tend to get overlooked.
Thanks, @seantilleycommunit, for granting me writing permission here :)
@jasonrobinson: Say, I'm a bad programmer guy.
Relay receives a post from a pod
Relay already has a cached list of pods and what hashtags they want so relay will deliver post to pods that are interested in one or more of the hashtags in this post. Relay is not for public message keeping - it will delete any posts as soon as they have been pushed out.
Could I misuse your proposal in any way by running a modified version of the code, which does not delete any posts?
It would come in handy, if you could list the information, you want to "store" in the directory/hub, to better judge this proposal.
@ryunoki well, since all the posts are public that would go through the relay, what does it matter if someone would? :)
You could already do it, just start saving posts from large popular pods by following a few hundred popular tags.
Actually the relay way you would only get a subset of posts - the more relays, the less posts that go through each relay. Say 5 relays, you would only get approx 1/5 of public posts from opt-in pods, and even then only those with one or more hashtags.
By proposal, the hub would not store anything else than data related to which pods should receive which tags. So something like a dictionary with pod host and N tags that it wants.
I'm trying to consider worst cases to improve the proposal, Jason. That's all :)
my federation protocol proposal:
https://github.com/loziniak/diaspora_federation
In my opinion the big question is:
Is it better make following of hashtags be part of the protocol (like Maciek's proposal).
Or is it better to make a search-endpoint be part of the federation, which can be used to search for postings with hashtags (and maybe users and other stuff).
Both ways will work, but which way is more reliable and more performant? Is there any third option?
Can you tell more about the search-based approach? When the search would be performed and how often? By whom and on which servers? What exactly would be searched for?
There is more than one possible search-approach. Jason for example would like some central search-server(s) like friendica or redmatrix have. But it would also be possible to have a search-endpoint on each pod that might be called by "neighbor" pods periodically or only if a user requests a search. But those details are not the question at this early stage, I think. The big question is still what do we want: pushing the news or pulling the info?
Maybe better than wonder and debate, it would be better to try one way, and when it’s not ok, then try another. There are quite a few ideas for developers to choose from. Maybe we should let them decide what is easier/faster to implement?
Interesting proposal @macieklozinski - not a bad concept imho. Would love to hear from the more federation-stuff experienced devs.
Although imho I still think federating public posts should be outsourced outside pod software itself. Podmins are already complaining about heavy sidekiq processes - keeping public post federation in the core code would be a big burden to all pods.
Would need to do a simulation to calculate really :P
But I agree that we should just do something :) Any sane implementation would be cool.
I first tried Diaspora a few years ago by joining a pod with lots of users on it, and loved that right after creating my account I had posts appear in my feed that matched the tags I was interested in. I finally returned to D* a couple weeks ago to help with development, and was disappointed after setting up my own pod how lonely it feels without public posts from the rest of the network being pushed to me! So I'm glad to see so many here who agree that federation of public posts is a very important feature for D*.
Doing this right is not trivial, but I think a DHT-based (Distributed Hash Table) solution might be the right fit. I'm not an expert on the various flavors of DHT out there, but after doing some research it looks like Pastry might be a good choice. In particular, there is already a publish/subscribe application called Scribe designed for it, and an open source implementation called FreePastry. In a nutshell, the Pastry+Scribe combination provides O(log(n)) average routing hops between nodes, high tolerance of nodes entering/leaving the network, automatic load balancing of topic subscription management and notification multicasts across the network, and the ability to structure the routes between nodes in a way that minimizes overall latency/bandwidth (or other relevant metric.) The idea would be that every D* pod would run a node in the DHT network, which would allow the overhead associated with managing subscriptions and disseminating public posts to subscribers to be automatically shared among all the network's nodes.
I am going to run some simulations using FreePastry+Scribe to verify this approach for a "hashtag subscription" feature for D*, but before digging in too deeply I have a few questions:
1) FreePastry is written in Java 5 and its architecture takes advantage of Java threads and asynchronous IO. It might not be a trivial exercise to port this to Ruby+Rails, and I think in any case it would be best to keep any new DHT component cleanly decoupled from the main D* application. What is the development team's stance towards adding a JVM instance (OpenJDK 6/7) as a new tier to the pod design? I think it would complicate pod setup and configuration a little, but probably not too much.
2) FreePastry's implementation uses its own TCP connections for messaging, and UDP for keep-alives. Its architecture is very modular, and so it's probably possible to proxy all its communication through D*'s existing https-based communication scheme if absolutely necessary. But in the interests of performance and clean design, the much better approach is probably to let the Pastry tier handle its own P2P network communications, and let it communicate through a web services API locally with the Ruby+Rails tier and/or directly with the local database for everything else. In terms of security, https isn't needed, since we're dealing with public posts; all that needs to be done is make sure that the payloads carried by Pastry are cryptographically signed. The downside to the separate P2P communication is that it would add to the firewall setup requirements for a pod (although FreePastry already has the ability to use uPnP to open its own ports to the internet, where supported.) How does the development team feel about the idea of requiring additional ports to be opened between pods and the internet?
3) Are there any parts of the database that are designed to be usable as an interface, i.e. not meant to be controlled and accessed exclusively by the Ruby+Rails and Sidekiq tiers? (For example, is it "legal" to write posts directly to the database without going through the Ruby+Rails app?)
With a DHT-based P2P network to leverage, other useful functions could eventually be added in a scalable way to D*, for example (a) load-balancing of requests for relatively large content like images, so that for example an image in a post from a tiny pod that gets wide distribution in the D* network doesn't result in that pod being swamped with requests for the image from the entire network, (b) network-wide features like user search/discovery, (c) helping other D* functions to scale as the network grows, such as propagation of public posts from originators to followers.
Thanks for your time, I appreciate any feedback or advice you may have!
@markwilliams2 I love the idea, and I'm also researching the problem and possible solutions. See point #2 on my list: https://wiki.diasporafoundation.org/User:Danger89
I hope that we can come in contact with each other to discuss this futher and finally try to implement a working prototype.
Let's place is like this: I think to make Diaspora a good decentralized social network, the relational database should be removed and replaced by an Apache Cassandra database (for example), at-least a database which is vertically scalable with high availability & reliability.
This is also known as 'NoSQL database environment'. This means in fact.. that the current project as it is should be rewritten almost entirely (!) to compete against existing social networks like Facebook, Google+, Twitter, etc.
So... Good luck :)
@melroyvandenberg I think you will find little support for a complete rewrite - unless you do it yourself ;) You can always fork and replace the DB.
diaspora* started with MongoDB which didn't work for some reason. Do you mind explaining in more detail why you think a NoSQL database would be better than a relational database, for diaspora*?
@jasonrobinson I try to dive deeper into distributed hash table (DHT), which makes it possible to search users within the network (regardless of the pod). But the same will work both public messages and hashtags, etc.
A non relational database and using hashing (key-value) will make this possible. That is the current problem of Diaspora, the decentralized network isn't really connected, a pod floats in the Internet currently.
Maybe this site gives you a better explanation of the implementation details of the idea of DHT (funny sentence):
http://www.rackspace.com/blog/cassandra-by-example/
Interesting. I was thinking to something like that but not with the relay servers.
Could you emphasize the interest of having a relay server and of having several ones (with random use for each post) ?