V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zxCoder
V2EX  ›  问与答

请教关于 serverless 数据库的问题

  •  1
     
  •   zxCoder · 2021-08-15 09:33:03 +08:00 · 1026 次点击
    这是一个创建于 985 天前的主题,其中的信息可能已经有所发展或是发生改变。

    各大服务商提供的云数据库和 serverless 数据库有什么比较大的区别呢,虽然说文档上讲得天花乱坠,不过本质上,难道不是都一样,连接然后,读写数据吗

    那对于 serverless 应用来说,每次执行一个函数都需要建立一个数据库连接,这样只要并发数稍微多一点,数据库就承受不了吧,所以 serverless 的数据库是有对这种情况做什么优化吗

    但是单纯从介绍和提供的文档来看没看出特别的不同

    4 条回复    2021-08-15 17:42:41 +08:00
    shot
        1
    shot  
       2021-08-15 11:29:42 +08:00
    https://www.jeremydaly.com/aurora-serverless-the-good-the-bad-and-the-scalable/

    Max Connections
    A major limitation of relational databases in serverless architectures is the maximum number of concurrent connections allowed by the database engine. While FaaS services like Lambda may scale infinitely (in theory anyway), massive spikes in volume can quickly saturate the number of available connections to the underlying database. There are ways to manage connections in serverless environments (also see Managing MySQL at Serverless Scale), but even with Aurora Serverless, this still appears to be a possible limiting factor.

    AWS uses the following formula for generating the max_connections value for Aurora instances:

    log( ( <Instance Memory> * 1073741824) / 8187281408 ) * 1000 = <Default Max Connections>

    A db.r4.xlarge instance with 30.5 GB of memory for example would have a default max_connections value of 2,000.

    log( (30.5 * 1073741824) / 8187281408 ) * 1000 = 2000
    whileFalse
        2
    whileFalse  
       2021-08-15 12:00:30 +08:00
    我觉得你口中的 Serverless 数据库可能有两种。以下全部以 AWS 的服务举例。

    1. 为 Serverless 型应用优化的数据库,在应用程序不使用连接池而是一次性连接时也能很好的工作。例如 DynamoDB 和 RDS Data API,前者是原生使用 HTTP 协议,后者是在标准的 MySQL 等数据库前面加上了 HTTP 层代理。

    2. 数据库本身以 Serverless 形式驱动,不用管理数据库实例,可以无缝伸缩,例如 DynamoDB 和 Aurora Serverless 。前者本身是 NoSQL,从设计上就是完全无缝伸缩的;后者则是分别在两个层面实现伸缩:Aurora 本身实现了存储层面的无缝伸缩; Aurora Serverless 通过预先准备计算资源池,进一步在计算层面实现无缝伸缩,因而实现了完整的无缝伸缩。
    zxCoder
        3
    zxCoder  
    OP
       2021-08-15 12:07:23 +08:00
    @shot 看完好像还是没啥实质的东西....
    shot
        4
    shot  
       2021-08-15 17:42:41 +08:00
    @zxCoder #3

    从文章里可以看到,Aurora Serverless 可以根据负载情况自动调整配置规格,最大规格可以支持到最多 6000 连接数。

    如果把一个连接数看作一个并发访问,那相当于是能支撑一个「千万用户级」的系统服务。
    虽然达不到 Lambda 的无限伸缩(理论上),但对于 90%(其实我想说 99%)以上的业务场景也基本够用了。

    如果期望支持更大的并发,需要组合其它技术来支撑,比如说缓存、消息队列、拆分服务。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2832 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:31 · PVG 20:31 · LAX 05:31 · JFK 08:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.