(undone) MIT6.824 Lecture1 笔记

参考1MIT课程视频:https://www.bilibili.com/video/BV16f4y1z7kn/?spm_id_from=333.337.search-card.all.click&vd_source=7a1a0bc74158c6993c7355c5490fc600

参考2某大佬笔记:https://ashiamd.github.io/docsify-notes/#/study/%E5%88%86%E5%B8%83%E5%BC%8F%E7%AD%96%E7%95%A5/MIT6.824%E7%BD%91%E8%AF%BE%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-01

参考3mapreduce论文:https://pdos.csail.mit.edu/6.824/papers/mapreduce.pdf

参考42021MIT6.824schedule:http://nil.csail.mit.edu/6.824/2021/schedule.html


最近工作上遇到了一些高并发和一致性的问题,发现并行代码要写好、写的没有错误、DEBUG 真的很难。故决定学习 MIT6.824 来补充一下这方面的知识。

我们开始看 Lecture 1 吧,先来看教授的课程。

分布式系统的定义:多个计算机(而不是多处理器)通过网络连接,只能通过发送接收数据包交互,来合作提供一些服务。

分布式系统的意义:1.通过并行提高速度 2.容忍错误,一部分计算机宕机、其它计算机能继续工作 3.提高安全性。把安全相关的服务放在一台机子上,其它服务放在别的机子上

最直接的分布式系统应用:数千万人同时访问的网站,自然需要分布式系统提供服务

分布式系统中的难点:
1.许多并发的部分
2.当一部分计算机故障时,分布式系统应该能够使用剩余的计算机继续正常提供服务
3.想要实现分布式系统在理论上的性能优势并不容易

这门课的实验是模拟的,假装有很多台机器在运行服务,但实际上是在你自己的机子上单机跑。有兴趣可以看看是怎么实现的

分布式系统的主题有:
1.Fault tolerance (分为 available(部分机子宕机依然能运行) 和 recoverability (宕机的计算机能够恢复并重新加入工作))
2.Consistency 一致性。(并行、并发情况下,如何保证结果不会错误?并发 bug 是很常见的)
3.性能 Performance (包括 Throughput 和 latency)

性能和前两者往往冲突,所以这就需要工程上的 trade-off

教授简单介绍了 MapReduce:一种框架,让非专业人士能够轻易写分布式代码

以下是一个案例
如果让 N 台计算机去统计全世界所有书籍的各单词计数,那么比较好的方式是:
1.把所有 corpus 平均分成 N 份
2.每台计算机统计分给自己的 corpus,产出 <单词,计数> 键值对
3.所有计算机都产出键值对后,统一把这些键值对相加,得到最后的结果
前两步叫 Map,最后一步叫 Reduce
教授指出,最昂贵的步骤是 mapper 和 reducer 之间的 shuffle 操作,这个到论文中再仔细看吧
在这里插入图片描述

TODO:here

要添加一个统计展示组件 Footer.vue,可以按照以下步骤进行操作: 1. 在 src/components 目录下创建一个名为 Footer.vue 的文件,编写统计展示组件的模板和样式,例如: ```html <template> <div class="footer"> <span>已完成 {{ doneCount }} 项</span> <span>未完成 {{ undoneCount }} 项</span> </div> </template> <style> .footer { display: flex; justify-content: space-between; align-items: center; padding: 10px; background-color: #f0f0f0; } </style> ``` 2. 在 App.vue 中导入 Footer 组件,并在模板中使用它,例如: ```html <template> <div> <h1>Todo List</h1> <input v-model="inputValue" @keyup.enter="handleAddItem"/> <ul> <li v-for="(item, index) in todoList" :key="index"> <span :class="{ 'done': item.done }" @click="handleToggleDone(index)">{{ item.content }}</span> <button @click="handleDeleteItem(index)">删除</button> </li> </ul> <footer-component :done-count="doneCount" :undone-count="undoneCount"></footer-component> </div> </template> <script> import Footer from './components/Footer.vue' export default { components: { 'footer-component': Footer }, data() { return { todoList: [ { content: '学习 Vue.js', done: true }, { content: '学习 React', done: false }, { content: '学习 Angular', done: false } ], inputValue: '' } }, computed: { doneCount() { return this.todoList.filter(item => item.done).length }, undoneCount() { return this.todoList.filter(item => !item.done).length } }, methods: { handleAddItem() { if (this.inputValue.trim() === '') return this.todoList.push({ content: this.inputValue, done: false }) this.inputValue = '' }, handleToggleDone(index) { this.todoList[index].done = !this.todoList[index].done }, handleDeleteItem(index) { this.todoList.splice(index, 1) } } } </script> ``` 3. 在 Footer.vue 中定义 props 接收父组件传递的数据,例如: ```js export default { props: { doneCount: { type: Number, required: true }, undoneCount: { type: Number, required: true } } } ``` 4. 在 Footer.vue 中使用 props 中接收的数据,例如: ```html <template> <div class="footer"> <span>已完成 {{ doneCount }} 项</span> <span>未完成 {{ undoneCount }} 项</span> </div> </template> ``` 这样就完成了添加统计展示组件 Footer.vue 的操作。在 App.vue 中使用 footer-component 标签即可展示 Footer.vue 组件的内容。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值