Skip to content

Instantly share code, notes, and snippets.

View thangchung's full-sized avatar
:electron:
Sharing is caring

Thang Chung thangchung

:electron:
Sharing is caring
View GitHub Profile

So, are you building microservices? Take a look at a few of these symptoms, and decide for yourself:

  • ❌ A change to one microservice often requires changes to other microservices
  • ✅ Deploying one microservice requires other microservices to be deployed at the same time
  • ❓ Your microservices are overly chatty
  • ❌ The same developers work across a large number of microservices
  • ✅ Many of your microservices share a datastore
  • ✅ Your microservices share a lot of the same code or models
@thangchung
thangchung / Event-stream based GraphQL subscriptions.md
Created September 1, 2021 03:09 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

  • JAVA : 1-4 MB
  • C++ : 1 MB
  • Python : 64 KB
  • Golang : 2-4 KB
  • Node.js : Single threaded and event driven

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@thangchung
thangchung / CachePipelineBehavior.cs
Created November 6, 2020 04:15 — forked from lurumad/CachePipelineBehavior.cs
Adding cache to MediatR
public class CachePipelineBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
{
private readonly IDistributedCache cache;
private readonly ILogger<SGUKAspNetCore> logger;
public CachePipelineBehavior(
IDistributedCache cache,
ILogger<SGUKAspNetCore> logger)
{
Ensure.Argument.NotNull(cache, nameof(cache));
@thangchung
thangchung / latency.txt
Created September 29, 2020 04:03 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@thangchung
thangchung / BaseRepository.cs
Created July 20, 2020 03:24 — forked from pmbanugo/BaseRepository.cs
Implementation of the Repository and UnitOfWork pattern using Entity Framework.
// A generic base repository which other repositories (if needed) can inherit from
public class BaseRepository<TEntity> : IEntityRepository<TEntity> where TEntity : class
{
internal DataContext context;
internal DbSet<TEntity> dbSet;
public BaseRepository(DataContext context)
{
this.context = context;
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@thangchung
thangchung / psql_useful_stat_queries.sql
Created April 24, 2020 09:40 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@thangchung
thangchung / install.md
Created March 10, 2020 18:12 — forked from Ryanb58/install.md
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found

/app # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-243-gf26e75a186 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-229-g087f28e29d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]