[Q&A List + Recording] Meetup | Why TiDB Serverless for Data Applications

Hi everyone! Thank you for your interest in our TiDB Serverless TechTalk! We hope you found the session with Xin Shi from PingCAP insightful and valuable.

:film_projector: Access the Recording: Why TiDB Serverless for Data Applications - YouTube

During the TechTalk, Xin demonstrated how TiDB Serverless empowers developers with true pay-as-you-go pricing while catering to the needs of handling large-scale data and real-time analytics using the real-world example of OSS Insight. We received numerous interesting questions from the audience, and in response, we’ve gathered a Q&A list and invited our technical experts to provide comprehensive answers.

:mag: Q&A Highlights:

Q: How long has your DBaaS been live?
A: TiDB Serverless has been beta since Nov 2022, and it’s just GA’ed in July 2023.

Q: Couldn’t find example on TiDB data service to insert / update. Most online content I came across was for select queries.
A: Right now TiDB Cloud Data Service (TCDS) supports 2 HTTP methods: GET/POST, and the recommended usage is shown in the tooltip of product:

Users when they use TCDS from lambda as opposed to using drivers will be:

a) The requests made will be HTTPS and will not use AWS backbone network (in case of lambda) and instead will make a internet call which may add to latency.
b) After certain point there will be a cost associated with using TCDS which can be avoided when using drivers.
c) TCDS will come in handy in situations where a suitable driver cannot be found.
d) For projects that involves pure Database interaction Lamba is an overhead as TCDS can scale just like Lambda does.
e) Other place where TCDS can play important role in tandem with Lambda are AWS specific integrations that natively integrates with Lambda. For example eventbridge natively integrates with Lambda so in that case you can configure Eventbridge to invoke a lambda as a rule and then from lambda use TCDS, you can also use drivers but the coding effort to de-serialize and then serallize a payload coming from lambda can be saved if using TCDS directly.

Q: Is there a limit on number of db connections when going server less. Assuming several micro services are connected to same sever less instance.
A: the default setting is 500. You can change it by demand. System Variables | PingCAP Docs

Q: Would love to hear about a benchmark / QPS with the bare minimum config. I have around 80% write and 20% reads
A: For benchmarking, you can refer to these documents:

Q: Do commits happen after data is written to disk or before that. (Just curious)
A: TiDB use two-phase commit algorithm to implement distributed transaction. So the first phase would be prewrite(prepare) phase, it will write all the data on disk across distributed nodes. When the transaction is considered committed(usually execute a COMMIT statement), then the second phase will write a commit operation to the disk, then the transaction will be committed. Any error occur before the commit operation, the whole transaction will be rollbacked. Reference: Transaction - TiDB Development Guide

Q: When using serverless function. Would you recommend using database connection style or TiDB data service. Since there is no pooling advantage when using serverless functions.
A: It depends. Data service over HTTP is suitable for REST-style data applications. But pay attention to the limitations of data service such as data size limits. Database connection style over TCP is a traditional way.
Use data service for small and flexible data applications may be a good practice. Also, you can turn to database connection style if you find data service can not meet your needs.

Not sure the exact definition of “serverless function” you mentioned, if you are talking about sth like AWS lamda, it really depends on your scenarios.
TiDB Cloud Data Service(TCDS) will help you manage your DB connection sessions, resources, billing, auth and sth more, and the only thing you need to care about is your SQL statement, which makes it a fully managed Backend-as-a-service(BEaaS). But it will limit the response to 2000 rows and 30s of processing timeout, if you want to raise it, please file a support ticket. BTW, the feature of “user defined functions” is in the development phase inside TCDS right now and will be released shortly, and any feedback is welcomed.
And meanwhile direct connection will absolutely give you all the freedom to control your db connections.

On a case by case basis users can evaluvate whether to use TiDB Cloud Data Service (TCDS) from within a serverless function such as AWS Lambda, in the process of such an evaluvation consider the following ,

  • When TCDS endpoint request is made from within a serverless function such as AWS Lambda, although the request made will be secured i.e will use HTTPS it will not use the cloud providers backbone network and instead will make call over the internet which can add some latency to the overall operation.

  • Both serverless functions and TCDS can add up to the total cost.

  • TCDS can be an ideal choice when a suitable driver is not available and/or you want to get out of version dependency chaos.

  • For certain projects that involves pure database interaction, serverless function can be an overhead and may simply play a role of a facade layer adding to the cost and latency. Since TCDS can scale just like Lambda it would be a preferred choice here.

  • Other areas where TCDS can play an important role in tandem to serverless functions are cloud specific integrations. As an example eventbridge natively integrates with AWS Lambda so in that case you can configure Eventbridge to invoke a lambda as a rule and then from lambda use TCDS, you can also use drivers but the coding effort to de-serialize and then serialize a payload coming from lambda can be saved if using TCDS directly.

Q: Is there a limit on QPS with data service. Especially with inserts?
A: Right now the rate limit for each data application is 100 requests per minute per API key, no matter it’s a GET or POST request, you can ask for raising it by submitting a support ticket by following below hint.

Q: Is there a way to use TiDB serverless on the edge/closer to customers?
A: TiDB Cloud Data Service(TCDS) can be used on the edge environment now. Besides, a serverless driver over HTTP protocal which supports raw SQL is on the way.

Tips: If you have any questions about the above content, you can ask in the comment section! thanks :hugs: