
Coding Blocks
Things to Know when Considering Multi-Tenant or Multi-Threaded Applications
Episode guests
Podcast summary created with Snipd AI
Quick takeaways
- Prioritize data isolation in multi-tenant applications to ensure that each tenant's information remains securely separated and protected.
- Implement robust authentication and authorization systems to effectively verify tenant identities and manage resource access.
- Focus on scalability during architectural design to accommodate growth in both tenant numbers and individual data volumes.
- Optimize performance through efficient database queries and comprehensive monitoring to maintain speed as the number of tenants increases.
Deep dives
Podcast Introduction and Hosts
The hosts introduce the episode with a light-hearted interaction that highlights their camaraderie. They stumble briefly over the episode number, clarifying that it's episode 241. Each host introduces themselves, with playful banter about their names and past episodes. This creates an engaging atmosphere right from the onset, reflecting their informal and friendly dynamic.
Community Engagement and Upcoming Events
The hosts discuss listener engagement, mentioning a review received from a listener, Colin Ferry, on Spotify. They also highlight an upcoming event, Atlanta Dev Con, scheduled for September 7, 2024, encouraging listeners to participate. Additionally, they reference another event, Def Central Floor, which includes a call for speakers. These discussions emphasize the importance of community involvement and networking within the tech space.
Dad Jokes and Humor
The segment reveals the hosts' penchant for humor as they share dad jokes, with varied reactions among them. One joke involves a play on words about a 'nosy pepper,' eliciting some lighthearted banter. The exchange shows how the hosts utilize humor to maintain an engaging tone and keep the audience entertained throughout the episode. This segment reinforces their engaging style, making complex topics more relatable.
Async Programming in Multi-Tenant Applications
The hosts delve into the challenges of asynchronous programming while discussing multi-tenant applications. They emphasize the risks of data leakage across threads, particularly when using shared objects in asynchronous operations. They suggest that proper locking mechanisms are crucial to avoid race conditions and protect data integrity. This discussion underscores the complexities associated with multi-threaded environments and the importance of effective programming practices.
Considerations for Multi-Tenant Code
The hosts reflect on the insights provided by AI tools like Claude for writing multi-tenant code. Key considerations include data isolation and ensuring that tenant data remains securely separated. They discuss authentication and authorization mechanisms, emphasizing the need for robust systems to verify tenant identity. The conversation outlines practical strategies for managing tenant-specific configurations to balance feature customization and core code integrity.
Performance and Monitoring Strategies
Further discussing multi-tenant applications, the hosts touch on the importance of performance optimization and the impact of database queries. They emphasize implementing comprehensive logging and monitoring processes to track tenant usage and errors. The conversation also highlights the necessity of understanding the scalability requirements as tenant numbers grow. These insights are crucial for achieving effective performance management and maintaining smooth operations in multi-tenant architectures.
Event Planning and Collaboration
As the episode progresses, the hosts discuss the importance of planning events and collaborating with community leaders like Javier. They emphasize the value of networking and sharing experiences within the tech industry to foster growth. The conversation illustrates how attending or participating in community events can provide opportunities for learning and professional development. This segment promotes engagement among listeners and encourages them to contribute to the local tech community.


It’s time to talk about the types of things you should consider when diving into multi-tenant applications and things to be especially aware of if you attempt to make things faster by going multi-threaded at the same time. Join us as Allen continues is non-winning / non-losing streak, JZ is taken out by a storm, and Outlaw continues to ignore the notes for the intro to the show…
News
Reviews
- Spotify – Colum Ferry
Upcoming Events
- Atlanta Dev Con
September 7th, 2024
https://www.atldevcon.com/ - DevFest Central Florida on September 28th, 2024
https://devfestflorida.com/
Episode
- Single vs multi-tenanted applications and multi-threaded programming
- Be very careful about sharing state when doing anything in multi-threaded AND multi-tenanted applications
What are some important things to consider when writing multi-tenanted applications – per Claude
As mentioned in the episode, Claude’s answers seem to be very database heavy
- Data isolation: Ensure that each tenant’s data is securely separated and inaccessible to other tenants.
- Authentication and authorization: Implement robust systems to verify tenant identity and control access to resources.
- Scalability: Design the architecture to handle growth in both the number of tenants and data volume per tenant.
- Performance: Optimize database queries and resource allocation to maintain speed as tenant count increases.
- Customization: Allow for tenant-specific configurations and features without compromising the core codebase.
- Monitoring and logging: Implement comprehensive logging and monitoring to track usage, errors, and performance per tenant.
- Maintenance and updates: Design the system to allow for updates and maintenance with minimal disruption to tenants.
- Data backup and recovery: Implement tenant-specific backup and recovery processes.
- Compliance and data regulations: Ensure the system can meet various regulatory requirements that may differ by tenant.
- Tenant onboarding and offboarding: Create efficient processes for adding new tenants and removing old ones.
- Good feature flagging support?
- Tracing / OpenTelemetry
Can you elaborate on the data isolation?
Data isolation is crucial in multi-tenant systems to prevent unauthorized access and ensure data privacy. Here are some key strategies to ensure data isolation:
- Separate databases
- Use a separate database for each tenant
- Pros: Strong isolation, easier compliance
- Cons: Higher maintenance, potentially higher costs
- Use a separate database for each tenant
- Shared database with separate schemas
- Each tenant gets their own schema within a shared database
- Pros: Good isolation, more cost-effective than separate databases
- Cons: Requires careful access control, potential for errors
- Each tenant gets their own schema within a shared database
- Shared schema with tenant ID
- Use a single schema but include a tenant ID column in each table
- Pros: Most cost-effective, easiest to maintain
- Cons: Highest risk of data leaks, requires vigilant query filtering
- Use a single schema but include a tenant ID column in each table
- Row-level security
- Implement database-level security policies to restrict access based on tenant ID
- Particularly useful with shared schema approach
- Encryption
- Encrypt sensitive data, potentially using tenant-specific keys
- Adds an extra layer of protection even if other measures fail
- Connection pooling
- Use separate connection pools for each tenant to prevent session mixups
- Query filtering
- Always include tenant ID in queries, preferably at the database level
- Use ORMs or query builders that automatically add tenant filters
- API and application-level checks
- Validate tenant ID in all API calls and application logic
- Implement middleware to enforce tenant-specific access
Resources / Mentions
- Salable Postgres product – Citus
https://www.citusdata.com/ - Envelope encryption if you’re wanting to use tenant specific keys for multi-tenanted encryption – one approach is envelope encryption
https://en.wikipedia.org/wiki/Hybrid_cryptosystem#Envelope_encryption
https://cloud.google.com/kms/docs/envelope-encryption - OWASP multi-tenant or “Cloud Tenant” Isolation
https://owasp.org/www-project-cloud-tenant-isolation/ - C#’s Parallel.ForEach method – the easy way to do parallel processing in C#
https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.parallel.foreach?view=net-8.0 - Can’t remember why we linked episode 11, but here it is!
https://www.codingblocks.net/podcast/episode-11-design-patterns-part-1-you-create-me/
Tips of the Week
- Speculative fix? If you’re not sure that your fix is going to work, or you can’t reproduce the problem then consider over-communicating it and keeping artifacts such as screenshots of what you attempted.
- It’s useful for communication, but also for looking back when and if you start second guessing yourself.
- Shapez 2 is a cool refactoring, automation, and puzzle game. It’s similar to Factorio, but with a heavier emphasis on refactoring and puzzles.
https://store.steampowered.com/app/2162800/shapez_2/ - Kotlin – measureTimeMillis
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.system/measure-time-millis.html - Google skills – learn and get certified in Google Cloud https://www.cloudskillsboost.google
- Pay for a year’s worth of training for $299 and get $200 towards a certification – over $1,500 value https://www.cloudskillsboost.google/payments/new https://www.cloudskillsboost.google/subscriptions
- Pay for a year’s worth of training for $299 and get $200 towards a certification – over $1,500 value https://www.cloudskillsboost.google/payments/new https://www.cloudskillsboost.google/subscriptions
- From Ivan Kuchin – Dasel – like JQ except it does JSON, YAML, TOML, XML and CSV with zero runtime dependencies
https://github.com/TomWright/dasel - Google Cloud products in 4 words or less
https://cloud.google.com/blog/topics/developers-practitioners/back-popular-demand-google-cloud-products-4-words-or-less-2022-edition
https://googlecloudcheatsheet.withgoogle.com/