---
# System prepended metadata

title: Experiment with Lotus / Visor continued.
tags: [AWS, Daily update, docker]

---

# Experiment with Lotus / Visor continued.
###### tags: `Daily update` `AWS` `docker`

## Understanding Ian's response
> Hi! State refers to the information known about the actors on the chain such as the sectors sealed by a miner or the deals made. Some miners have hundreds of thousands of sectors so their state is large because it includes details about every sector. A tipset is lightweight and consists of just the blocks containing messages. The messages are used to change actor state such as adding a sector, transferring tokens or making a deal. To apply a message from a tipset you have to have a copy of the current state of the actor so it knows what to change. The snapshots contain the minimum needed to start syncing the chain: the current state of every actor plus all the blocks up to this point.

So this implies that FilFox and Filscan simply have a chosen the [Full Chain](https://docs.filecoin.io/get-started/lotus/chain/#syncing) option and therefore they have messages that trace back to genesis, but their state is also only 2000 epochs back.

总结一下，Filfox和FIlscan能看到genesis 的tipset正常，因为full chain 同步tipset，但是state特别大，里面有真实的sector，所以无法同步。message是修改state的指令。

## AWS sales rep talk

目前确定的事：
1. Confirmed the two stage plan. Use on-demand plan for experiments with DB。 Reserved 1 year plan for long-term.
3. Confirmed pricing and instance type.
    r5.8xlarge EC2 + 2TB gp2 SSD EBS.
4. Tenacy option 应该选shared. 共享依然是锁定在机器上，不会有我担心的live migration影响性能或短线的问题。只有spot instance 才会断线。
5. 选convertible 而不是standard，为10%的价格差我们可以在instance family里随意更改大小。将来扩张很有用。
下一步继续和销售要讨论的事
1. Amazon Activate项目，我们需要一个官网。具体还差什么
2. 我们的机器resource utilization怎么检测，是否要换更大或更小的机器
3. 机器硬件具体配置是什么。Zen 和icy lake之后的硬件会有加成。
4. 是否可以改架构，改成用EC2 + RDS服务。我猜不好，因为是通过网络传输数据，应该没有EBS来的快。
5. 谁懂系统瓶颈在哪里？SSD是可以换gp3增加到16K IOPS，甚至64K IOPS，但是压测工具是什么怎么用，怎么找瓶颈，我需要学习。


## 学习docker
Tux:
> docker容器我记得在16年的时候我好像还出版过一本书的，叫做《docker实战》啥的，不过是很早之前的事了，不过如果要找网上资料的话，也可以上[dockone.io](http://dockone.io) 看看，里边的实用资料比较多，我在里边也有不少文章的

I'll try to read *docker in action*.

## GCP setup for lotus 
Trying to use the $300 credit.

Concerns:
1. Should I deploy a container image to this VM instance? To do this, I must use a container-optimized OS. 
Answer: No, because container optimized OS must have everything in docker containers. And I'm not sure if an official docker container for Lotus exists on DockerHub.
I checked, there is none.

There are [unofficial docker images](https://docs.filecoin.io/reference/#containers-and-virtualization)
Github of one of them [link](https://github.com/glifio/filecoin-docker)


2. Should I use ubuntu 20.04 as the OS?
Answer: Maybe. [This official DigitalOcean droplet](https://marketplace.digitalocean.com/apps/filecoin-lotus?refcode=f37c84619fb2) seems to use it.

**20.03 LTS minimal, balanced persistent disk 10GB** for now. Who knows.
What is ubuntu pro 20.04LTS? No, i'm not using that for now.

TODO: What is a custom image? there's the custom images option.
I see a snapshot option, maybe I can snapshot my image and save it.

WARNING:
 Bad request: multiple X-Origin headers. Under multiple X-Origin headers. 
 
Attached disk type:
- [x] balanced persistent disk
- [ ] SSD persistent disk
- [ ] standard persistent disk
- [ ] local SSD scratch disk
- [ ] extreme persistent disk

size: 2048GB

3. Failed. I cannot request 2048GB of persistent disk due to my trial account. I cannot raise my quota as well. The limit is 250GB??
I need to activate my account to raise quota.
[Raise quota](https://cloud.google.com/compute/quotas)

I think I will just use 250GB for now..

Failed again. N2D_CPU quota is at 8. I think I will need to activate my account to raise the quota.

## May be helpful to follow a tutorial on GCP usage.
I will follow 2 tutorials
1. Create a Linux virtual machine instance
Learned: I can connect to my instace via the webpage by clicking the SSH key button. I didn't need a project-wide SSH key.

I certainly don't need to run ssh-keygen on my own computer.

3. Build a compute engine application
Run two instance, backend instance install and runs mongodb. Frontend instance runs [Sample NodeJS app.](
    https://github.com/GoogleCloudPlatform/todomvc-mongodb.git)
Learned: Click on the *cloud console* icon to open console. On first use, I setup my SSH key pair. Logged my passphrase on my Laptop.

> Set up the backend instance
In this section, you install a MongoDB database on the backend instance to save your data.
Connect to the instance
Connect to the VM using SSH:
gcloud compute --project \
    "ace-server-319803" ssh --zone \
    [backend-zone] [backend-name]
Replace [backend-zone] and [backend-name] with the zone and name of the instance that you created.
If this is your first time using SSH from Cloud Shell, follow the instructions to create a private key.
It may take several minutes for the SSH key to propagate.
Install the backend database
Update packages:
sudo apt-get update
Install the backend MongoDB database:
sudo apt-get install mongodb
When asked if you want to continue, enter Y.
Run the database
The MongoDB service starts when you install it. You must stop it so that you can change how it runs:
sudo service mongodb stop
Create a directory for MongoDB:
sudo mkdir $HOME/db
Run the MongoDB service in the background on port 80:
sudo mongod --dbpath $HOME/db \
    --port 80 --fork --logpath \
    /var/tmp/mongodb
Exit the SSH session and disconnect from the backend instance:
exit

>Set up the frontend instance
In this section, you install the dependencies for the web app and then install and run the frontend web app.
Connect to the instance
Connect to the VM with SSH:
gcloud compute --project \
    "ace-server-319803" ssh --zone \
    [frontend-zone] [frontend-name]
Replace [frontend-zone] and [frontend-name] with the zone and name of the instance that you created.
Install the dependencies
Update packages:
sudo apt-get update
Download npm:
curl -sL \
    https://deb.nodesource.com/setup_10.x \
    | sudo -E bash -
Install Node.js and git:
sudo apt-get install git nodejs
When asked if you want to continue, enter Y.
Install and run the frontend web app
Clone the sample app:
git clone \
    https://github.com/GoogleCloudPlatform/todomvc-mongodb.git
Install the app dependencies:
cd todomvc-mongodb
sudo npm install -g \
    npm-check-updates
sudo ncu -u
sudo npm install
Adjust the code to point to the correct port:
sed -i -e 's/8080/80/g' server.js
Start the to-do web app:
sudo nohup nodejs server.js \
    --be_ip [backend-internal-ip] \
    --fe_ip [frontend-internal-ip] &
Replace [backend-internal-ip] and [frontend-internal-ip] with the internal IP addresses for the instances that you created. These IP addresses are listed for each instance in the VM instances table.
The nohup command redirects output to the specified nohup.out file. Expect to see:
nohup: ignoring input and appending output to 'nohup.out'.
Exit the SSH session and disconnect from the frontend instance:
exit


**Resources**
1. [Samples on Github](http://googlecloudplatform.github.io/)
2. [Load balancing setup](https://cloud.google.com/compute/docs/load-balancing/)
3. [transfer files to VM](https://cloud.google.com/compute/docs/load-balancing/)
4. [*Run containers](https://cloud.google.com/compute/docs/containers)