Giter VIP home page Giter VIP logo

blog-1's Introduction

A blog system written in Go and running on App Engine.

Data model

There's three kind of objects in the datastore:

  • User
  • Post
  • Comment

Both posts and comments have a user as an ancestor, which it's the author of the text. This gives strong consistency for user queries when he accesses his posts and comments.

In addition to having this information in the datastore keys, there's also the same information as a property of both Post and Comment. They both have a Author property, containing the encoded key of a User.

Finally, comments have a PostKey field with the key of their corresponding post.

Application design

The application queries are done in two steps which are actually executed concurrently.

The first step queries the 10 newest posts in the datastore. This query is eventually consistent.

The second step queries the 10 newest posts for the current user. This query is strongly consistent.

Then we merge both lists of posts, removing duplicates and keeping the sorting.

Once we have this list of posts we fetch the comments for all the posts concurrently.

Fetching the comments for a posts is again done in two steps, one for all the comments in the post, another for all the comments on the post authored by the current user.

At the end of this we obtain the list of N newest posts with all its comments, and we ensure that any interaction of the current user is displayed to him.

Performance

The datastore that we have developed allows high performance limiting the entities in a given entity group. Entity groups handle the interactions of a given user, meaning that a user won't be able to comment or post more than once a second. This seems a reasonable limit.

On the other side, as many comments as needed can be done in a given post, and the list will be eventually consistent.

Finally, the usage of memcache to keep the list of the latest 10 posts and its comments limits the reads on the datastore.

blog-1's People

Contributors

campoy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.