Pages

Developing a highly scalable blog from scratch - Part I

Why do the easy way?

First of all, I just want to do as everyone does, have a blog and post about interesting things. I don’t know much about anything but I do like software development and software architecture, so I thought, maybe I should write a blog about these things. But, as every software engineer, I do want to do it in a hard way.
First, I’m writing in a Notepad++ which, by the way, is one of the best text editor ever made, and I’m also writing about developing a blog system (kind of inception here).
Second, I want to have this blog running in AWS using whatever is provided as a managed service in AWS, and of course, I want to start from scratch.

Well, this is not going to be an easy task, I’ve been thinking about what a blog requires and I came up a list of requirements:
  • Must be accessed from anywhere in the world
  • Must be resilient and highly available
  • Must be fast
  • Must permit adding new posts
  • Must ensure that only authorized bloggers can add new posts
  • Must allow comments
  • The posts Must be searchable
  • Must be indexed by search engines, I mean, must appear on Google search
  • Must send notifications about new comments to the author of the post
  • Must allow multiple authors
What now? How do I start this endeavor?

I won’t achieve all the Musts at once, I’ll start doing the basic of the basics, and incrementally improve it until I have all the musts in place.
Let’s start from the beginning, having a domain 😉.
I already have a domain wolf.srv.br, it’s a Brazilian domain with my last name translated to English, Lobo to Wolf. But this domain zone naming resolution is provided by the Registro.br, the single entity in Brazil that holds all Brazilian domains. The first change I will do is to start using Route 53 to host my public domain.
I will open my AWS console and I will create a new Hosted Zone in Route 53.
  • Open Console
  • Open Route 53
  • Click on ‘Create Hosted Zone’
  • Fill ‘Domain Name’ with ‘wolf.srv.br
  • Select ‘Type’ as ‘Public Hosted Zone’

Voilà, AWS now resolves my domain. The last change I have to do is to move whatever DNS entries I had previously at Registro.br to Route 53 and change the Name Server
configuration at Registro.br to define the new name server provided by Route 53 as the master Name Server to my domain.

After the Hosted Zone is created you can see 4 NS entries, these are the ones I need to set up at Registro.br so all the other DNS servers redirect the naming resolution
requests to Route 53.

Ok, now I have a new DNS service providing resolution to my domain. The next step is to create a basic webpage and make it available for the world.
To start, I will create an S3 bucket (add a link to S3 from AWS) to host all my static files.
  • Open Console
  • Open S3 Bucket
  • Click Create Bucket
  • Provide Bucket name: blog.wolf.srv.br (remember, this name must be unique in the region you are creating the bucket) ** Route 53 requires to have the bucket name equals to the blog URL
  • On Iten 3 - Set permissions, uncheck the box ‘Block all public access’ (I do want to have this site accessible from anywhere, don’t I?)
  • Finish creating the Bucket
  • Click on the Bucket created
  • Go to Properties
  • Click at Static Website Hosting
  • Select Use this bucket to host a website
  • Type index.html in the ‘Index document’
  • Click Save
Ok, I have an S3 Bucket, which can hold all static assets, now I want to have a home page.
First, I create an index.html file
<html>
    <head>
        <title>Complicated things</title>
    </head>
    <body>
        <h3>This is my blog</h3>
    <body>
</html>
Now I need to upload the file to the S3 Bucket:
  • Open AWS Console
  • Go to S3 Bucket
  • Click on the Wolf-Blog bucket
  • Select the index.html file
  • Click Next
  • On Manage public permissions, select ‘Grant public read access to this object(s)’
  • Click Upload
Awesome, I have an index.html file hosted in an S3 bucket, how do I see this webpage?
Ok, there is an easy way to test it, while you are still in the S3 bucket page:
  • Click on Properties
  • Click Static website hosting
  • Click on the URL just after the ‘Endpoint’
Wow, now I see ‘This is my blog’! Amazing, well at least it seems to be amazing.
Let’s do one last configuration, the Endpoint (URL) that I’m using to access the index.html file is not what I want, I want to access the blog at blog.wolf.srv.br.
To make it work I need to create an Alias entry at Route 53 to resolve the requests to blog.wolf.srv.br to the S3 bucket endpoint:
  • Go back to AWS console
  • Open Route 53 service
  • Click at ‘Hosted Zones’
  • Click at Wolf.srv.br hosted zone
  • Click at ‘Create record set’
  • On ‘Name’ field type ‘blog’ (this must be the same name as the S3 bucket)
  • On Type, select ‘A’
  • Select Alias - Yes
  • On Alias Target: you should see your S3 bucket under S3 bucket group, select it blog.wolf.srv.br (s3-website-eu-west-1)
  • Click Create
  • Click Create Record Set
Now I can access my webpage using my domain, happy times.
Let’s continue on the next post.

Output



P.S.: I hope I can make this blog available to you or else, it will be a loss of time.

----------------------------
Related articles:

Loé Lobo

5 comments:

  1. Worth reading your blog!

    ReplyDelete
  2. Hello Loè, thanks for writing this post series, I was in fact, looking to create my own blog from scratch without using any CMS. That way I can learn how to host and build a webpage and create my blog (2 birds with one shot). But before I move on I would like to ask you, h

    - How much do you pay to AWS for this basic set up?
    - I do not foresee to have many visits in my blog the first months, so how much will the minimum payment be to have this site on AWS without any visits?
    - Also is there a way to have the blog on AWS but not open to the public and once ready open it to the world as a way to reduce costs?

    ReplyDelete
    Replies
    1. Hi Oscar, I hope you are doing well.


      You can use the AWS Calculator to estimate your costs AWS Calculator. I created an example, based on the requirements of this article (Route 53 and S3 bucket) with some traffic, and you can check it out here Article estimation costs.

      You can use the S3 bucket with or without authentication while still making it privately accessible. If you don't want to use authentication, you will need to use a Private VPC, and this is the AWS article about it Private S3 without authentication.

      You can also configure AWS CloudFront to provide an authentication layer for accessing your S3 files. You can find more information at Serving private content using Amazon CloudFront AWS Lambda@Edge.


      Please reach out if you need more information.


      Thanks

      Delete
    2. Thanks for your reply and the calculator resource, it is very insightful.

      Sadly it is not a viable option for me since I don't think I can justified the cost. I will find other hosting that are a better fit for my idea.

      Thanks for your help Lobo.

      Delete
  3. I'm happy to see the considerable subtle element here!.


    notepad++ for mac download

    ReplyDelete