Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodejs的一些理解 #45

Open
zonglang opened this issue Sep 6, 2019 · 1 comment
Open

nodejs的一些理解 #45

zonglang opened this issue Sep 6, 2019 · 1 comment

Comments

@zonglang
Copy link
Owner

zonglang commented Sep 6, 2019

健壮性

像apache这样的服务器,是使用多线程响应多用户请求,当某个请求的线程上抛出的异常没被捕获,只会影响当前这个线程,不会影响其他请求。

捕获异常

  • try-catch
    很好用,但是无法捕获异步任务中的错误
  • uncaughtException
    能捕获所有异常,但是会丢失堆栈信息
  • domain
    能够捕获异步中的异常,但是不稳定

阻止异常

  • 良好的编程习惯
    异步报错作为回调的第一个参数
  • 单元测试
  • 日志记录

cluster多线程架构

类似于nginx的主从模式,主线程调度任务,工作线程执行任务

守护进程

由于一下原因,进程挂掉后需要重启

  • 代码异常
  • 内存泄漏
@zonglang zonglang changed the title nodejs健壮性 nodejs的一些理解 Sep 6, 2019
@zonglang
Copy link
Owner Author

zonglang commented Sep 6, 2019

事件驱动

js是基于回调函数实现的异步编程
async可以进程异步流程的控制

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant