R0uter's Blog AWS on the cloud in mind

R0uter's Blog was first run on the virtual host,Can only be operated from the panel,no authority,Very awkward to use。In addition, anyway, I got the server to run over the wall proxy service,Then simply moved the blog to the VPS。So I started my vps tossing journey。In a blink of an eye, ten years have passed,I also ran on Vultr's VPS later. 4 year。of course,A lot has happened in between,I did cnswift, did drop boxed input method,There is also a macOS version of the drop-off input method... So this $20 a month on the vps,In addition to running three wordpresses,It also started to run three authorized API services for input methods.。Of course there is also an access statistics system,A phpmyadmin for easy database administration - obviously,There is also a MySql service that provides data access for all the above services,correct,There are also drop-off input method instructions for this static website。

After so many years of maintaining servers with commands,I've been fascinated by panels for a long time...there are many panels to choose from,Unfortunately,None of them are compatible with the existing configuration - of course this is understandable,After all, the existing configuration is different for everyone,Location、The version is also weird。So I never had the chance to experience。

Later I learned that AWS entered the web hosting market,Cheap Lightsail Idea Is Nice...Tested,Domestic access speed is also ok,So I decided to put everything on the entire R0uter's studio on the cloud! (After all, "cloud computing" is no longer a new term.,And I'm still using the "traditional" stuff like virtual private servers...it's easy to be a single point of failure, right)


I did a tidy up:

  1. i can use a Lightsail run my blog、Studio and Swift programming language translation,This cost is $5/mo(minimum of 3.5,I didn't choose,detailed below);
  2. Static website of input method manual,Can be dropped into S3 container,Overhead is roughly $0.1/mo which is negligible;
  3. The authorization service for those input methods happens to be written in Python,Can be seamlessly migrated to Lambda,Due to the small amount,Same overhead,can be ignored;
  4. while the database,can be separated,Lightsail for wordpress,no extra cost。Because I don't store a lot of data myself,Comes with 40G space is enough。Input method orders and other data are stored in DynamoDB,Convenience Lambda use,Due to the small amount of data,not much reading and writing,Never use up the free credit。

Such,Once the migration is complete,My monthly fixed expenses become 5 US dollar,But because of cloud computing,So stability and security have been improved,And subsequent development and maintenance have become much easier。


difficulty

In fact, for cloud computing platforms like AWS,Technology is not difficult。It is difficult to understand some necessary concepts。such as permissions:Since many AWS services,Access between different services requires configuration permissions,They have their own set of configuration modes role。In addition, in order to facilitate the authorization of external services,There is also a configurable account system AIM。

Also, because the service points are very fine,Some of our commonly used functions may have ready-made tools for automated deployment in batches,And this automatic deployment function,another service,So when you choose the function,pay attention to,Otherwise, it is very likely that you have manually configured it and found that there is a ready-made solution.。

static website

The first thing I migrated was a static website,Nothing to say about this,GitHub compiles eBooks with Actions,Then push to a pre-opened bucket.,I chose the bucket in Hong Kong,Domestic direct connection speed is also good。Then I use AWS CloudFront custom domain name to do cdn for this bucket,This will enable https。

One problem is that in this way, the advantage of the bucket in Hong Kong is gone.。But surprisingly,Cloudfront's CDN is also very fast in China,So that's it for now。I attribute this to the fact that not many people use AWS's CloudFront,So the country is not walled。(Reference Cloudflare,Almost half of the IP is blocked)

It is worth mentioning that,In fact, you can do without cdn,It is also possible to use nginx reverse proxy directly,This will also provide https。Of course because I migrated this first,Didn't think of this plan at the time。

R0uter's Blog

Static websites are simple,but WordPress more troublesome。My first thought was to use WordPress which natively supports multisite,And Lightsail has this Application that can be deployed directly。but unfortunately,Configuration of multisite mode is more complicated than I expected,Almost all commonly used plugins are charged separately for multi-site mode (often free for single-site mode)。So I consider another option,How about I drive three small $3.50 Lightsails? This monthly cost is 10.5 US dollar,also acceptable。

But running WordPress directly has its own problems,The preset configuration is also weirder than I expected,Configuration files are hard to find,are not in the standard directory。such asR0uter's BlogNeed to modify nginx configuration to achieve pseudo static,Need to use certbot for automatic https certificate renewal... but unfortunately,You can't achieve either。

I think after thinking,Since the heart panel has been around for a long time,Why don't you try it?

The final implementation is using the Plesk panel Application for $5/mo。Fast and easy!

Due to the performance requirements of Plesk itself,3.5 Lightsail at a price point that doesn't support Plesk。

I cut off access to the stats system,Use a WordPress plugin instead WP Statistics, And phpmyadmin plesk also comes with。In addition, this option also has a built-in Plesk basic license,support up to 3 A domain name,i only have two,If the subdomain also counts,just three,enough。just create a website on plesk,add database,Then the WordPress directory is packaged and migrated。After matching the database account password,the migration was successful。Since my blog has pseudo-static enabled,So you need to configure pseudo-static separately,Finally, go to the "permanent link" and click to save the configuration,Just refresh the rewrite rules。

cnswift.org

This is not pseudo static,Much simpler than R0uter's Blog,no more。

LogStudio

R0uter's studio is actually a subdomain of logcg.com,Fortunately, plesk supports creating subsites,Subsites will use the same database account as the main site by default,But the data directory is separate。We can manually create a database association to subsites on plesk,So they are independent。But the website directory will still be in the same parent directory.。

Caching

If you use e.g. WP Super Cache such plugins,Then it's better to delete all caches and turn them off before migrating。First of all, if there are a lot of cached files, it will take up space,compression、Decompression takes time,upload and download the same。In addition, because the absolute path of the website directory has changed,will cause the default cache file to not be found,And then cause the website to crash... Now it's hard to do,Because you have no idea what the problem is。

CDN

I try to use CloudFront Sitewide cname cdn for WordPress,But unfortunately,This will confuse WordPress itself,redirection loop。Either https access cdn, cdn http back-to-origin is redirected again to https loop,Either a loop caused by a different domain name。In short,I ended up using the traditional method,Only replace the domain name of the static file to realize the static file cdn。

There is a problem when the cdn caches the fonts,There will always be an error that cannot be hit,Need to add extra rules in nginx:

 

Certificate Authority Service

This is more troublesome,Fortunately, it's all Python,I first want to use lambda to achieve,But then I found out that there is a combined service called CloudFormation,Works with AWS's own tools SAM,You can use the description file to automatically deploy lambda+api gateway+lambda at one time。

Here I am encountering a difficult problem is how to make the existing services seamlessly connect to the past,different from the web,As long as the user refreshes, it will be the new version,Drop-off input method this software requires users to update,The battle lines will be long...thanks for fighting the wall in the early years,With the experience of anti-generation Google back then,I reversed mine with an existing domain name Lambda API,In this way, the interface migration of these services is completely seamless to the client!

A little,at the time of retrogression,Pay attention to this setting:

cannot be $host


Summary

In fact, the use of Lightsail The reason why it is cheap is that he splits the CPU into "computing power" and sells it,Usually we rent a VPS, CPUs are calculated based on speed and cores,But not every service can always run all cores of the CPU,in contrast,in most cases,The CPU may be in a working state of about 20%。In this way, most of the computation is wasted.。Lightsail introduces fixed computing power and burst computing power,The server is running stably,Will be in the fixed allocation of computing power range,That is, the CPU usage 10%。If you encounter unexpected events such as plug-in upgrades,sudden increase in pageviews,The CPU usage can also soar to 100% Even 140%,This will consume your burst points。This point will automatically increase when there is no need for sudden computing power.。(of course,If you run out of points,That CPU performance will pin you to 10%,The server is running slowly。Obviously,This also means that this configuration is a bit low for your current state。)

In addition, Lightsail has been too streamlined (all are already selling money according to CPU computing power),It does not support dynamic expansion,Fortunately, it supports daily automatic snapshots,Therefore, AWS officially also recommends that snapshots be created directly when expansion is required.,Then buy the premium version,restore the snapshot。Anyway the static IP address is separate from another service,You just need to append the IP address from the old server to the new server,expansion is complete。

Don't forget to sync your firewall configuration,And the IPv6 address will change,Remember to update the domain name resolution record。

Another,Thanks to the snapshot feature,There is no need to use complex WordPress backup plugins to backup the entire site data weekly to Dropbox La~

 

Original article written by Gerber drop-off:R0uter's Blog » R0uter's Blog AWS on the cloud in mind

Reproduced Please keep the source and description link:https://www.logcg.com/archives/3803.html

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *