• AWS,  技术

    AWS Technology Usage

    Athena + S3 Tracking information. Cheap to save and pay on-demand DynamoDB Fast access. Known query pattern (Partition Key, Sorting Key). Scale up automatically if partition it right. TTL should be considered and dump historical data out. (how?) SQS RDS Elastic Cache Athena ECS Load Balancer Query S3s by SQL (Presto).

  • Design,  技术

    Domain Driven Design

    https://www.geeksforgeeks.org/domain-driven-design-ddd/ What is Domain? The word domain used in context of software development refers to business. domain logic == business logic. When we are developing software our focus should not be primarily on technology, rather it should be primarily on business (domain). Component Entity The instance of entity has a global identity and keeps same identify throughout lifespan. Identity never changes. It generally persisted as a row in DB and consists of value objects. Can we say one entity is one business object? Value Object Value Object has no identify. User is an entity and address is a value object. Services Service is a stateless class. Services is neither related…

  • 工具,  技术

    How to create a new repo in github?

    If you write codes only for your job and don’t really try to have your personal little projects you may never create a brand new project in repo even you have been written codes for years. So how to create a new repo in gitbut sounds easy but a lot of experienced developers may never do that. Int he other hand, whether he/she can create a repo without any trouble or google search is a arguable way to determine whether he/she is a passionate developers or not (no argument needed here, personal option).. Ok. let’s start. Normally when you build a new repo you may use third part bootstrap tool…

  • Docker,  技术

    Docker Container的命名

    因为下划线在域名中是非法的,所以HttpParser会认为这个是非法。但是在docker环境里面每一个container的名字是可能包含下划线的。当一个container试图访问另一个的时候最简单的方式就是通过container的名字,这个时候就会出错。 这个问题折腾了我2个小时。。 下面是异常 <head><title>HTTP Status 400 \u2013 Bad Request<\/title><style type=\"text/css\">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}<\/style><\/head><body><h1>HTTP Status 400 \u2013 Bad Request<\/h1><hr class=\"line\" /><p><b>Type<\/b> Exception Report<\/p><p><b>Message<\/b> The character [_] is never valid in a domain name.<\/p><p><b>Description<\/b> The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).<\/p><p><b>Exception<\/b><\/p><pre>java.lang.IllegalArgumentException: The character [_] is never valid in a domain name.\n\torg.apache.tomcat.util.http.parser.HttpParser$DomainParseState.next(HttpParser.java:994)\n\torg.apache.tomcat.util.http.parser.HttpParser.readHostDomainName(HttpParser.java:890)\n\torg.apache.tomcat.util.http.parser.Host.parse(Host.java:66)\n\torg.apache.tomcat.util.http.parser.Host.parse(Host.java:40)\n\torg.apache.coyote.AbstractProcessor.parseHost(

  • Java,  安全,  技术

    Java Agent的使用

    最近集成Rapid7 的tcell 安全agent到我们的application。在report里面可以显示各个api end point的访问情况和返回情况,并且还能检测xss等数据。好奇他们是怎么做的,顺手查看了文档,发现其实挺简单。其实就是在运行java程序的时候 加入 javaagent的参数。不同的framework tcell提供了不同的agent,比如说Sprint,Dropwizard。 javaagent是通过修改bytecodes的方式修改运行程序的。这里有一篇很好的文章介绍java instrumentation的: https://www.baeldung.com/java-instrumentation . 通过javaagent还能做挺多的其他东西,比如说: 动态的添加loghttps://lightrun.com/debugging-live-java-applications-with-lightrun/ Jolokia is an agent converting JMX to http based REST end points. https://jolokia.org/reference/html/agents.html#agents-jvm https://www.baeldung.com/java-instrumentation . 自定义任何东西 后记:我以为Sentry也是通过javaagent实现的,看了之后发现不是。

  • 性能,  技术

    Log对于程序运行速度的影响

    这个其实是老话题。但是在生产环境下真的对性能的影响还是很大的。下面是今天实际遇到的一个例子。 14:20的时候turn off log,以前的log是35k/min,减少到10k。 下面是处理速度的提高(除去无用log以外,反应traffic的log数量) 将近10倍的速度提升。 所以,如果看log过多,在我这个case里面一个单线程的程序每分钟produce30k的log,就直接把log level提高看一下性能区别。其实这样做反倒是最简单的。 但是其实真的产品环境下的各种metrics很重要。一个系统慢,应该能立刻看到哪里引起的慢。不过不知道怎么把log的时间单独剥离出来,显示log的运行时间。可能有library可以做这个事情?有人知道么? 顺便: 产品的各种security,不能做这个不能做那个,但是所有的engineer都可以ssh到所有的产品的instance,然后sudo -i. 这个合理么?😂

  • Design,  技术

    What makes it so hard to migrate to Micro service

    We have been tried for so many years but since we didn’t admit we failed officially there is no formal conclusion what went wrong? Or what really made it so hard. By reading this book Microservices patterns maybe there are couple of main reasons The user interaction is very hard to change.Distribute the data to different micro services would cause that it would be more complex to complete one complex tasks. For example, when a customer want to create a subscription we potentially need to create an account, create a subscription, even doing payment, invoice and etc. Since we are B2B business it make it very hard to change the…

  • Design,  技术

    Data Connect的消息处理机制

    Data Connect Service提供同步数据到第三方。数据的change是来自数据库binlog生成的CDC (Change Data Capture)。 在系统设计中有几个挑战 Ordering的问题。前端的service并不保证顺序。那Data Connect如何保证顺序呢?技术上来讲是不可能的。但是我们可以做到在不保证顺序的情况下依然能正确处理。方法是我们从最开始的服务开始引入了Versioning的概念。如果data connect拿到的对于某一条记录的event早于之前的event,我们就丢弃。这个逻辑我们叫stale checker。这个在sync的逻辑里是可行的。比如说我们有“Create->Update”,其实对于sync,create和update都是基于Id的upsert,如果我们拿到create晚一些,就直接丢弃。同样的“update->update”也没问题,当然前提是每次我们都是拿到整个记录的full payload,不然就会有问题。我们并没有field level的versioning。 Duplication。Duplication其实我们并不太在意,因为我们的服务基本上是Idempotent的,也就是说同样的消息可以被处理两遍,没问题。原因是update本来就可以重新执行,create也可以,因为我们是根据id来的。还有就是我们有stale checker其实就能解决很多的问题。 Partition. 最开始的版本没有separate topic。我们partition by billing account id。 好处有几个 减少一个tenant占用所有的consumer的问题。当然side effect是某一些consumer会比较慢,如果一个tenant traffic比较多。 减少row locking。 控制并发。其实并发的控制我们其实可以用Resillience4j – 远程方法调用的工具箱 里面提到的同步控制机制。但是也会有负面影响。 潜在的enhance workers。我们不应该consumer thread里面处理所有的东西。应该用workers,这样就更容易scale out。问题是我们还是要保证worker的同步问题。如果有两个update对于同一个billing account,我们要保证scale checker依然可以工作。 减少tenant之间的影响。应该可以用dedicated topic来做。当然机制可能会比较复杂。我们应该还是需要common pool来出来ad-hoc traffic