This is the main performance killer so far.
$ curl http://localhost:3000/v1/timeline/anonymous
{
"id": "0f8320aa-a31a-4edc-9bab-3643fd92c1ef",
"name": "Posts",
"user": {
"id": "0b1bd0dc-9f10-4002-bcff-3cc7e6e8c02e",
"username": "anonymous",
"type": "user",
"info": {
"screenName": "anonymous"
},
"statistics": {
"userId": "0b1bd0dc-9f10-4002-bcff-3cc7e6e8c02e",
"posts": "1",
"likes": "0",
"discussions": "0",
"subscribers": "1",
"subscriptions": "1"
},
"subscribers": [
{
"id": "fa7d253f-7a70-452f-924b-bda7953a5321",
"username": "test"
}
],
"subscriptions": [
{
"id": "e959db46-c2a5-4fee-95be-5f0aed0134a9",
"name": "Posts",
"user": {
"id": "fa7d253f-7a70-452f-924b-bda7953a5321",
"username": "test"
}
},
{
"id": "9b884493-8ec0-4fc6-8432-946e676aa660",
"name": "Likes",
"user": {
"id": "fa7d253f-7a70-452f-924b-bda7953a5321",
"username": "test"
}
},
{
"id": "4cd94d9e-4f2e-4682-b17f-3b04b6737133",
"name": "Comments",
"user": {
"id": "fa7d253f-7a70-452f-924b-bda7953a5321",
"username": "test"
}
}
]
},
"posts": [
{
"id": "88699b63-48b9-4ca5-b4f8-02909b3f4507",
"body": "Hello world",
"createdAt": 1380398266250,
"updatedAt": 1380398266250,
"comments": [],
"attachments": [],
"likes": [],
"createdBy": {
"id": "0b1bd0dc-9f10-4002-bcff-3cc7e6e8c02e",
"username": "anonymous",
"info": {
"screenName": "anonymous"
}
},
"groups": [
{
"id": "0b1bd0dc-9f10-4002-bcff-3cc7e6e8c02e",
"username": "anonymous",
"info": {
"screenName": "anonymous"
}
}
]
}
],
"subscribers": [
{
"id": "fa7d253f-7a70-452f-924b-bda7953a5321",
"username": "test"
}
]
}
The main thing to point out is anonymous user block that is duplicated across this json, furthermore I must say that the backend selects all of them separately casing massive performance degradation when there are lot of same users/objects on a page.
{
"post": {
"id": 1,
"title": "New post",
"body": "A body!",
"comment_ids": [ 1, 2 ]
}
}
{
"post": {
"id": 1,
"title": "New post",
"body": "A body!",
"comment_ids": [ 1, 2 ]
},
"comments": [
{ "id": 1, "body": "what a dumb post", "tag_ids": [ 1, 2 ] },
{ "id": 2, "body": "i liked it", "tag_ids": [ 1, 3 ] },
],
"tags": [
{ "id": 1, "name": "short" },
{ "id": 2, "name": "whiny" },
{ "id": 3, "name": "happy" }
]
}
this will kill two birds with kind of one stone: reduce network traffic and reduce number of selects to db.