tag:crieit.net,2005:https://crieit.net/users/tetsuya/feed tetsuyaの投稿 - Crieit Crieitでユーザーtetsuyaによる最近の投稿 2018-12-20T01:24:33+09:00 https://crieit.net/users/tetsuya/feed tag:crieit.net,2005:PublicArticle/14672 2018-12-17T22:31:40+09:00 2018-12-20T01:24:33+09:00 https://crieit.net/posts/2b5d146497604ef8579a96d76290daf8 マルチクラウド環境で低コストに始める個人開発 <p>こちらは、 <a href="https://crieit.net/advent-calendars/2018/technology">個人開発サービスに用いられている技術 Advent Calendar 2018</a> の16日目の記事です。前日は、 @SugiKent さんによる <a href="https://crieit.net/posts/GoogleAnalytics">GoogleAnalyticsはセグメントを切ってから本気</a> でした。</p> <h2 id="サービスについて"><a href="#%E3%82%B5%E3%83%BC%E3%83%93%E3%82%B9%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6">サービスについて</a></h2> <p><a target="_blank" rel="nofollow noopener" href="https://roastery.jp/">roastery.jp</a> という、コーヒー豆の焙煎所検索サービスを運営しています。</p> <p><a href="https://crieit.now.sh/upload_images/b9996439acaf7973249c30adaef35b385c179268e0fc5.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/b9996439acaf7973249c30adaef35b385c179268e0fc5.png?mw=700" alt="Screen Shot 2018-12-17 at 21.10.35.png" /></a></p> <p>残念ながら現状1円も生み出せていない状況ですので、レイテンシよりも安く運営することに重点を置き、常により良い方法を模索しています。現在の構成は下記の通りです。</p> <h2 id="現在の構成"><a href="#%E7%8F%BE%E5%9C%A8%E3%81%AE%E6%A7%8B%E6%88%90">現在の構成</a></h2> <div class="table-responsive"><table> <thead> <tr> <th>種別</th> <th>サービス</th> <th>価格(月額)</th> </tr> </thead> <tbody> <tr> <td>Domain Registration</td> <td><a target="_blank" rel="nofollow noopener" href="https://muumuu-domain.com/">ムームードメイン</a></td> <td>¥152 (年額¥1,825を12ヶ月で割った額で計算)</td> </tr> <tr> <td>DNS</td> <td><a target="_blank" rel="nofollow noopener" href="https://www.cloudflare.com/">Cloudflare</a></td> <td>$0</td> </tr> <tr> <td>Application Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://www.heroku.com/home">Heroku</a></td> <td>¥794 (7USD。1USD=113.4JPYで計算)</td> </tr> <tr> <td>Database Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://www.jawsdb.com/">JawsDB</a></td> <td>$0 (Heroku 経由での申し込み)</td> </tr> <tr> <td>Storage Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://cloud.google.com/storage/">Google Cloud Storage</a></td> <td>$0</td> </tr> <tr> <td>Application Performance Monitoring</td> <td><a target="_blank" rel="nofollow noopener" href="https://newrelic.com/">New Relic</a></td> <td>$0 (Heroku 経由での申し込み)</td> </tr> <tr> <td>Error Tracking</td> <td><a target="_blank" rel="nofollow noopener" href="https://sentry.io/">Sentry</a></td> <td>$0 (Heroku 経由での申し込み)</td> </tr> <tr> <td>Mail Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://gsuite.google.com/">G Suite</a></td> <td>¥500 (年額¥6,000を12ヶ月で割った額で計算)</td> </tr> <tr> <td><strong>合計</strong></td> <td>---</td> <td><strong>¥1,446</strong></td> </tr> </tbody> </table></div> <h2 id="改善案1"><a href="#%E6%94%B9%E5%96%84%E6%A1%881">改善案1</a></h2> <p>今回の記事を書くにあたり、いつの間にか <a target="_blank" rel="nofollow noopener" href="https://domains.google/">Google Domains</a> が .jp ドメインに対応していたことを知りました。Google Domains を利用することで G Suite が無料で使えるようになるので、こうなります。(無料/変更のないものは割愛)</p> <div class="table-responsive"><table> <thead> <tr> <th>種別</th> <th>サービス</th> <th>価格(月額)</th> </tr> </thead> <tbody> <tr> <td>Domain Registration</td> <td><a target="_blank" rel="nofollow noopener" href="https://domains.google/">Google Domains</a></td> <td>¥375 (年額¥4,500を12ヶ月で割った額で計算)</td> </tr> <tr> <td>Application Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://www.heroku.com/home">Heroku</a></td> <td>¥794 (7USD。1USD=113.4JPYで計算)</td> </tr> <tr> <td>Mail Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://gsuite.google.com/">G Suite</a></td> <td>¥0</td> </tr> <tr> <td><strong>合計</strong></td> <td>---</td> <td><strong>¥1,169</strong></td> </tr> </tbody> </table></div> <h2 id="改善案2"><a href="#%E6%94%B9%E5%96%84%E6%A1%882">改善案2</a></h2> <p>Mail Server に、ムームードメインが提供する<a target="_blank" rel="nofollow noopener" href="https://muumuu-domain.com/email/muumuu-mail">ムームーメール</a>を利用することでコストを下げられます。<br /> 実は、途中までムームーメールを利用していましたが、泣く泣く利用を諦めていました。</p> <p>以前、Object Storage として、DigitalOcean が提供する <a target="_blank" rel="nofollow noopener" href="https://www.digitalocean.com/products/spaces/">Spaces</a> というサービスを利用していたのですが、画像の表示速度が遅かったため、CDN を挟むことで解決を試みました。その時に選んだのが、Cloudflare でした。Cloudflare を使うために、DNSも変更する必要があったのですが、ムームーメールは、ムームードメインが提供するムームー DNS 経由でしか利用できないことが発覚。悩んだ末、ムームーメルを諦め、G Suite を契約しました。</p> <p>結局、その後に Google Cloud Storage であれば 5GB まで無料であることを知り移行したのですが、後に Space に Built-in の CDN が入るというニュースが飛び込んできた時は少し残念な気持ちになりました。</p> <ul> <li><a target="_blank" rel="nofollow noopener" href="https://blog.digitalocean.com/spaces-now-includes-cdn/">Spaces Object Storage Now Includes Built-in CDN</a></li> </ul> <p>その他、ムームー DNS を使うデメリットに ALIAS レコードが設定できないため、Heroku でホスティングする場合 root domain が設定できないという問題があったのですが、こちらも現在は解消されています。</p> <ul> <li><a target="_blank" rel="nofollow noopener" href="https://twitter.com/muumuu_domain/status/967953350850301953">ムームードメイン on Twitter: "ムームーDNSでALIASレコードが設定できるようになりました!</a></li> <li><a target="_blank" rel="nofollow noopener" href="https://devcenter.heroku.com/articles/custom-domains#add-a-custom-root-domain">Custom Domain Names for Apps | Heroku Dev Center</a></li> </ul> <p>G Suite の代わりにムームーメールを使うとこうなります。(無料のものは割愛)</p> <div class="table-responsive"><table> <thead> <tr> <th>種別</th> <th>サービス</th> <th>価格(月額)</th> </tr> </thead> <tbody> <tr> <td>Domain Registration</td> <td><a target="_blank" rel="nofollow noopener" href="https://muumuu-domain.com/">ムームードメイン</a></td> <td>¥152 (年額¥1,825を12ヶ月で割った額で計算)</td> </tr> <tr> <td>Application Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://www.heroku.com/home">Heroku</a></td> <td>¥794 (7USD。1USD=113.4JPYで計算)</td> </tr> <tr> <td>Mail Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://muumuu-mail.com/">ムームーメール</a></td> <td>¥54 (年額¥648を12ヶ月で割った額で計算)</td> </tr> <tr> <td><strong>合計</strong></td> <td>---</td> <td><strong>¥1,000</strong></td> </tr> </tbody> </table></div> <p>Cloudflare DNS とムームー DNS を比較し、パフォーマンスに差異がなければこの構成に戻すのもありですね。</p> <h2 id="2019年に向けたインフラ構成"><a href="#2019%E5%B9%B4%E3%81%AB%E5%90%91%E3%81%91%E3%81%9F%E3%82%A4%E3%83%B3%E3%83%95%E3%83%A9%E6%A7%8B%E6%88%90">2019年に向けたインフラ構成</a></h2> <p>今後、 roastery.jp はコーヒー豆の共同購入サイトとして生まれ変わる予定です。トランザクション量が増えてくると、最初にボトルネックとなりそうなのが Database Server です。Heroku の add-on として提供されているのは 5MB までが無料のプランです。しかし、自分で管理するのも面倒なので <a target="_blank" rel="nofollow noopener" href="https://www.conoha.jp/">ConoHa</a> の提供する <a target="_blank" rel="nofollow noopener" href="https://www.conoha.jp/database/">DBサーバ</a> が良さそうだと思っています。</p> <p>そうすると、Heroku を使い続けるメリットが薄れてくるので、Application Server もこのタイミングで移行先を検討するのが良さそうです。<a target="_blank" rel="nofollow noopener" href="https://www.vultr.com/?ref=7710444">Vultr</a> がずっと気になっているので使ってみたいです。</p> <p>また、 Google Cloud Storage も 5GB までが無料なので、移行先を検討する必要がありそうです。<a target="_blank" rel="nofollow noopener" href="https://aws.amazon.com/s3/">Amazon S3</a> も魅力的なのですが、あらかじめ料金が見積もりづらく、個人で使うには少し不安です。<a target="_blank" rel="nofollow noopener" href="https://www.digitalocean.com/products/spaces/">Spaces on DigitalOcean</a> に戻るのことを検討してみたいです。</p> <p>よって、このような構成になるかと思います。</p> <div class="table-responsive"><table> <thead> <tr> <th>種別</th> <th>サービス</th> <th>価格(月額)</th> </tr> </thead> <tbody> <tr> <td>Domain Registration</td> <td><a target="_blank" rel="nofollow noopener" href="https://muumuu-domain.com/">ムームードメイン</a></td> <td>¥152 (年額¥1,825を12ヶ月で割った額で計算)</td> </tr> <tr> <td>DNS</td> <td>ムームDNS</td> <td>$0 (ムームードメインの付属品)</td> </tr> <tr> <td>Application Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://www.vultr.com/?ref=7710444">Vultr</a></td> <td>¥397 (3.5USD。1USD=113.4JPYで計算)</td> </tr> <tr> <td>Database Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://www.conoha.jp/database/">ConoHa DBサーバ</a></td> <td>¥500</td> </tr> <tr> <td>Storage Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://www.digitalocean.com/products/spaces/">Spaces on DigitalOcean</a></td> <td>¥567 (5USD。1USD=113.4JPYで計算)</td> </tr> <tr> <td>Application Performance Monitoring</td> <td><a target="_blank" rel="nofollow noopener" href="https://newrelic.com/">New Relic</a></td> <td>Essentials (無料) プランで様子見</td> </tr> <tr> <td>Error Tracking</td> <td><a target="_blank" rel="nofollow noopener" href="https://sentry.io/">Sentry</a></td> <td>Developer (無料) プランで様子見</td> </tr> <tr> <td>Mail Server</td> <td><a target="_blank" rel="nofollow noopener" href="https://muumuu-mail.com/">ムームーメール</a></td> <td>¥54 (年額¥648を12ヶ月で割った額で計算)</td> </tr> <tr> <td><strong>合計</strong></td> <td>---</td> <td><strong>¥1,670</strong></td> </tr> </tbody> </table></div> <p>現在の構成よりも ¥224 のコストアップで抑えられそうです。また、現在の構成は US リージョンに固まっているのですが、日本/シンガポールとアジア圏にまとめられそうで、レイテンシを抑える効果も期待できそうです。</p> <p>来年は個人サービスで1円以上稼ぐことを目標に頑張ります!</p> <h2 id="まとめ"><a href="#%E3%81%BE%E3%81%A8%E3%82%81">まとめ</a></h2> <p>現状を整理することで、コスト削減の見通しが立ち、お正月休みの宿題もできました。Advent Calendar っていいですね。</p> <p>明日は @__shinji__ さんです。お楽しみに〜。</p> tetsuya