---
title: "Discussion on \"Rust + Actix + CosmosDB (MongoDB) tutorial API\" | Hashnode"
description: "Discussion on \"Rust + Actix + CosmosDB (MongoDB) tutorial API\". Intro\nWhen working on one of my projects I decided to create simple logging API and Rust seemed like a perfect choice to learn some new tech. Same goes for going with Azure CosmosDB which now offer free tier that is perfect for learning and small per..."
url: "https://hashnode.com/posts/rust-actix-cosmosdb-mongodb-tutorial-api/60d84427de92ef110afdeffe"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Rust + Actix + CosmosDB (MongoDB) tutorial API](https://jbarszczewski.com/rust-actix-cosmosdb-mongodb-tutorial-api?utm_source=hashnode&utm_medium=feed)

Intro When working on one of my projects I decided to create simple logging API and Rust seemed like a perfect choice to learn some new tech. Same goes for going with Azure CosmosDB which now offer free tier that is perfect for learning and small per...

Jun 27, 2021 · 7 min read · jbarszczewski.com  
Updated Jul 18, 2021  
Read the article

-   [#rust](https://hashnode.com/tag/rust)
-   [#tutorial](https://hashnode.com/tag/tutorial)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#mongodb](https://hashnode.com/tag/mongodb)

## Written by

[Jakub Barszczewski](https://hashnode.com/@jbarszczewski)

@jbarszczewski · London

  
[View profile](https://hashnode.com/@jbarszczewski)

## Responses 1

Markdown supported · ⌘↵ to post

[Benjamin Eder](https://hashnode.com/@bennyboer)

[Feb 10, 2022](https://hashnode.com/posts/rust-actix-cosmosdb-mongodb-tutorial-api/60d84427de92ef110afdeffe/comment/62051a56b6c216065a35d96b)

Hi there! Thanks for the tutorial. Pretty sure you do not need to use Mutex for sharing the MongoDB client instance between threads.

Comment from docs of `Client`:

> `Client` uses [`std::sync::Arc`](https://doc.rust-lang.org/std/sync/struct.Arc.html) internally, so it can safely be shared across threads or async tasks.

[Jakub Barszczewski](https://hashnode.com/@jbarszczewski)

[Feb 11, 2022](https://hashnode.com/posts/rust-actix-cosmosdb-mongodb-tutorial-api/60d84427de92ef110afdeffe/comment/62051a56b6c216065a35d96b#reply-62062a879e350308247feef3)

Hi Benjamin, Thank you for reading it! As for Mutex and Arc they serve different purposes and complement each other. Arc is used for reference counting and making sure you can safely pass and access object from multiple threads/tasks, and Mutex makes sure only one can change it at a time by putting a lock on it.

But you're right, we could remove the Mutex in this situation as the Arc is all we need. Great spot! :)
