{"id":56,"date":"2018-12-18T13:19:08","date_gmt":"2018-12-18T13:19:08","guid":{"rendered":"http:\/\/cbaduk.net\/w\/?p=56"},"modified":"2018-12-18T13:19:08","modified_gmt":"2018-12-18T13:19:08","slug":"hi","status":"publish","type":"post","link":"https:\/\/cbaduk.net\/w\/?p=56","title":{"rendered":"Hi!"},"content":{"rendered":"\n<p>First a quick introduction&#8230; I am a regular contributor of leela-zero (http:\/\/github.com\/gcp\/leela-zero\/) and this project is to see if it is possible to implement a scalable baduk-on-a-cloud website with a reasonable amount of cost (that is, don&#8217;t need to charge the users a fortune).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why?<\/h3>\n\n\n\n<p>To me, the main motivation doing these kind of things is to keep learning new things.\u00a0 I figured out that the only way to learn how to do things is to spend your time actually writing code.\u00a0 Additionally, the only way to make sure I can write things is&#8230; to actually write things.<\/p>\n\n\n\n<p>Naturally, writing a blog is also something that people can learn by&#8230; trying.\u00a0 Hence the whole effort is to learn how to write things and maintain a website that describes how things work.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What?<\/h3>\n\n\n\n<p>The main constraints that I have is:<\/p>\n\n\n\n<ul><li>This can only be a part-time thing.\u00a0 I have a full-time job and a family I need to take care of.\u00a0 Probably all I can spend is a couple of hours a week.<\/li><li>Since there is no commitments, this also means I can&#8217;t spend much $$$ buying equipment &#8211; the best I can do is use whatever stuff I have, plus maybe a few servers from some public cloud provider.<\/li><li><\/li><\/ul>\n\n\n\n<p>So a few design decisions:<\/p>\n\n\n\n<ul><li>Try spending compute resources on the local desktop (equipment I already have).\u00a0 GPUs on the cloud is expensive (A Tesla V100 runs around 80 cents per hour even on a preemptive mode) and having a single GPU running on the cloud is going to burn hundreds of dollars every month.\u00a0 I can&#8217;t blame any of the cloud providers because these cost $10K &#8211; hence whatever that can be offloaded to somewhere else&#8230; will be offloaded.<\/li><li>Make it scale &#8211; yes, this is what I am trying to learn.\u00a0 Making things scale includes implementing redundancy and having the appropriate failover mechanisms.\u00a0 The main goal is to eliminate as many single-point-of-failures as possible.<\/li><li>Write things from scratch whenever appropriate &#8211; there are many great open-source projects that provide pretty much anything.\u00a0 The whole point is to learn how to write code, not learn how to use somebody else&#8217;s code.<\/li><li>Don&#8217;t keep anything valuable on the cloud &#8211; it&#8217;s not like I can commit that I will take good care of other people&#8217;s private data.\u00a0 This is going to turn into a helluva mess with all sorts of bad practices everywhere.\u00a0 If things go wrong the last resort I have is to shut it down (and maybe leave a short apology).\u00a0 I can&#8217;t commit to clean up whatever disaster that might happen.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">So?<\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" width=\"198\" height=\"289\" src=\"http:\/\/cbaduk.net\/w\/wp-content\/uploads\/2018\/12\/image.png\" alt=\"\" class=\"wp-image-57\"\/><figcaption><br><\/figcaption><\/figure><\/div>\n\n\n\n<p>cbaduk is going to run on a four-tier architecture.\u00a0 Each component sends the request to the next tier and gets the response back &#8211; naturally, the request is the board state of the player, and the response is the next move.<\/p>\n\n\n\n<ul><li>The logic of the game itself will be written in javascript and run on the client web browser.\u00a0 The servers&#8217; main responsibility is to &#8216;think&#8217; &#8211; that is, play baduk.<\/li><li>The web frontend is responsible of communicating with the client &#8211; serve html files and provide data in some form of code the web browser can run.<\/li><li>The job queue distributes the gameplay to the relevant engines.<\/li><li>The engine plays baduk and generates the next move.<\/li><li>The NN server does the neural net evaluation for the engine.\u00a0 Normally the NN server is part of the game engine, but for compute efficiency it is better to do evaluations in parallel.<\/li><\/ul>\n\n\n\n<p>There are multiple instances of each component, and each component will attempt to query one of the multiple instances.\u00a0 For example, if one job queue is unresponsive, the web frontend will fall back to another alternative job queue.\u00a0 When the job queue finds one of the engines are not responsive, it will reroute the job to a different engine.<\/p>\n\n\n\n<p>(Well, eventually&#8230; for now the whole system consists of one web frontend, one job queue, and a couple of engines).<\/p>\n\n\n\n<p>The next couple of ports will cover each piece of component.<\/p>\n\n\n\n<p>Happy hacking \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First a quick introduction&#8230; I am a regular contributor of leela-zero (http:\/\/github.com\/gcp\/leela-zero\/) and this project is to see if it is possible to implement a scalable baduk-on-a-cloud website with a reasonable amount of cost (that is, don&#8217;t need to charge the users a fortune). Why? To me, the main motivation doing these kind of things &hellip; <a href=\"https:\/\/cbaduk.net\/w\/?p=56\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Hi!&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=\/wp\/v2\/posts\/56"}],"collection":[{"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=56"}],"version-history":[{"count":1,"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":58,"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions\/58"}],"wp:attachment":[{"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cbaduk.net\/w\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}