]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - ARCHITECTURE.md
Add migration script
[github/Chocobozzz/PeerTube.git] / ARCHITECTURE.md
index 65dd5b49d9553df21d1b33001def700905382526..ebcffd6cbf3d8c7fa9c0010c2b19f7168faf953d 100644 (file)
@@ -5,7 +5,7 @@
   - **Network:** several servers communicating each others with this software compose a network
   - **Pod:** a server of the network (inspired from Diaspora, no really signification)
   - **Friend:** a pod that communicates with yours
-  - **Origin pod:** the pod on which the video was uploaded and which is seeding the video
+  - **Origin pod:** the pod on which the video was uploaded and which is seeding (throught WebSeed protocol) the video
   - **Make friend:** the action of a server which will join a network (and so become friend with all pods that compose this network)
 
 ## Base
@@ -42,9 +42,9 @@
   * All the requests are retried if they failed
   * The requests are made at regular intervals to all pods of the network with a limit of parallel requests: if there are 1000 pods in the networks, the server won't make more than 10 requests in parallel
   * If there are no informations to send (no video addition/removal), no requests are made
-  * The requests are grouped: for example if the interval is 1 hour and an user upload 2 videos there will be only 1 request that contains the 2 videos informations
-  * The requests in the group are ordered: if an user add a video and remove it, we need to transmit these informations to the other pods in the same order
-  * The requests are grouped with a limit: if an user uploads 100 videos at a time, the information could be propagated in a few hours to do not make too big requests
+  * The requests are grouped: for example if the interval is 1 hour and a user$ upload 2 videos there will be only 1 request that contains the 2 videos informations
+  * The requests in the group are ordered: if a user add a video and remove it, we need to transmit these informations to the other pods in the same order
+  * The requests are grouped with a limit: if a user uploads 100 videos at a time, the information could be propagated in a few hours to do not make too big requests
   * If a grouped request fails the score is decreased by x points
   * If a grouped request is a success the score is increased by x points
   * The maximum of points would be defined
   * A pod is a websocket tracker which is responsible for all the video uploaded in it
   * A pod has an administrator that can add/remove users, make friends and quit friends
   * A pod has different user accounts that can upload videos
-  * All pods have an index of all videos of the network (name, origin pod url, small description, uploader username, magnet Uri, thumbnail name, created date and the thumbnail file). For example, a test with 1000000 videos with alphanum characters and the following lengths: name = 50, author = 50, url = 25, description = 250, magnerUri = 200, thumbnail name = 50 has a mongodb size of ~ 4GB. To this, we add 1 000 000 thumbnails of 5-15 KB so 15GB maximum
-  * After having uploaded a video, the server seeds it, adds the meta data in its database and makes a secure request to all of its friends
-  * If an user wants to watch a video, he asks its pod the magnetUri and the frontend adds the torrent (with WebTorrent), creates the HTML5 video tag and streams the file into it
-  * An user watching a video seeds it too (bittorent) so another user who is watching the same video can get the data from the origin server and the user 1 (etc)
+  * All pods have an index of all videos of the network (name, origin pod url, small description, uploader username, magnet Uri, thumbnail name, created date and the thumbnail file). For example, a test with 1000000 videos (3 tags each) with alphanum characters and the following lengths: name = 50, author = 50, podHost = 25, description = 250, videoExtension = 4, remoteId = 50, infoHash = 50 and tag = 10 has a PostgreSQL size of ~ 2GB with all the useful indexes. To this, we add 1 000 000 thumbnails of 5-15 KB so 15GB maximum
+
+          table_name | row_estimate |   index    |   toast    |   table
+        pod          |       983416 | 140 MB     | 83 MB      | 57 MB
+        author       |        1e+06 | 229 MB     | 140 MB     | 89 MB
+        tag          |  2.96758e+06 | 309 MB     | 182 MB     | 127 MB
+        video        |        1e+06 | 723 MB     | 263 MB     | 460 MB
+        video_tag    |        3e+06 | 316 MB     | 212 MB     | 104 MB
+
+
+  * After having uploaded a video, the server seeds it (WebSeed protocol), adds the meta data in its database and makes a secure request to all of its friends
+  * If a user wants to watch a video, he asks its pod the magnetUri and the frontend adds the torrent (with WebTorrent), creates the HTML5 video tag and streams the file into it
+  * A user watching a video seeds it too (BitTorrent) so another user who is watching the same video can get the data from the origin server and the user 1 (etc)
 
 ## Ideas
 
    user asks its pod -> user pod asks origin video pod -> origin video pod responds with the informations -> user pod responds to the user (and puts in cache the informations ?). We could extend this scheme with other informations
   * Redondance: if the origin pod is down, the video is not accessible anymore (no tracker/seeds). We could imagine a redondance between pods that keep seeding the video
   * Server could transcode the video to lower qualities (cost in CPU and disk space)
-  * Server could seed at the demand: for now the server seeds all the videos but it has two drawbacks:
-    - Seeding has a cost (if a pod has 1000 videos it could be an issue)
-    - After a restart the server has to reseed all the videos (with 1000 videos it could long)
-  If this solution is choosen, the frontend has to notify the origin pod that it has to seed the video
   * Add subtitles to videos
   * Avoid stocking friends URL schemes (http/https)