Coder Thoughts Piotr Mionskowski's thoughts on software, technology, architecture, design patterns and programming in general.

Piotr Mionskowski

  • How to deploy Lambda function with CloudFormation?

    11 March 2018 aws, cloudformation, lambda, and cloudform

    How to deploy Lambda function with CloudFormation?

    Serverless deployments are popular these days. With a minimal cost you can have your own code wait and respond to various events. AWS Lambda, Azure Functions are just 2 examples of serverless offering from the biggest cloud providers. For a long time I had thought about them only in the context of ad-hoc setups not suitable for a long term development. This was until I found out that you can, with a little effort, version and deploy the serverless API just as a traditional back-end. In this post I am going to show how to deploy AWS Lambda functions with the help of the tool Adam created at Bright Inventions called cloudform.

  • How to call a load balanced ECS service?

    06 March 2018 aws, ecs, cloudformation, elb, and cloudform

    How to call a load balanced ECS service?

    A service running ECS can call plethora of AWS APIs. It can read messages from queues, publish messages to SNS topics, query a database. These are all valid ways to communicate with the service. However, often the most appropriate way is to call the service by an HTTP API. In this post I’ll describe how to configure an ECS service running inside VPC so that other services can call its API.

  • How to deploy a service to Amazon Elastic Container Service with CloudFormation?

    19 February 2018 aws, ecs, cloudformation, and zuul

    How to deploy a service to Amazon Elastic Container Service with CloudFormation?

    Containers are becoming the standard way of deploying software. Every cloud vendor now offers one or multiple ways to run containers on their platform. Most of our clients uses AWS to host their SaaS solution. As part of a new development for one of our clients we have decided to move away from Elastic Beanstalk and embrace containers. Amazon Elastic Container Service is an orchestration service that supports Docker containers and is generally available for over a year. Given our small development team it seemed like the best choice since it takes away most of the cluster management headaches. In this post I will describe how we deploy a container to ECS using CloudFormation.

  • In-memory database tests with Querydsl

    12 February 2018 kotlin, querydsl, hibernate, jpa, and database

    In-memory database tests with Querydsl

    Writing tests is an important skill of a software engineer. I used to write lots of very focused, narrow unit tests. However, I often found such tests to hinder refactoring and barely help in catching regressions. Whether such issues were caused by my poor design choices or are intrinsic to unit tests is not the focus of this post. However, the fact is that nowadays I tend to write more coarse-grained, integration style tests. There is one downside to such approach: speed. For instance, using Hibernate with a full fledged database is relatively slow compared to using a fake repository implementation. Today I write about abstracting the database access using Querydsl in a way that aids testing.

  • How to publish a library to a Maven repository with the maven-publish plugin

    06 February 2018 maven, jcenter, jvm, gradle, and kotlin

    How to publish a library to a Maven repository with the maven-publish plugin

    A seasoned developer now and then creates a piece of code that he or she would like to reuse in a different project. When such time comes it is useful to know how to publish a library so that it can easily be incorporated into a different project. In this post I will describe how to publish a Kotlin library to JCenter with maven-publish and com.jfrog.bintray Gradle plugins.

  • Use ShouldKO for better assertion messages

    17 January 2018 junit, hamcreset, kotlin, assertion, and tests

    Use ShouldKO for better assertion messages

    Most of us write tests these days. Whether they are unit, integration, end-to-end or performance tests once written we often do not go back to them until they fail. It is thus vital to have a clear assertion message when a test fails.

  • Multi tenancy task scheduler

    04 January 2018 spring, mvc, spring-boot, multi-tenant, reactive, and reactor

    Multi tenancy task scheduler

    Last time I showed how to extend Spring default request handler adapter so that we are able to schedule or reject incoming requests. The goal of the TenantTaskCoordinator is to: queue requests for processing limit the maximum number of concurrently processed requests reject requests after the maximum queue size is reached interrupt processing of a request upon an upstream subscription disposal

  • Multi tenancy in Spring MVC

    12 December 2017 spring, mvc, spring-boot, multi-tenant, reactive, and reactor

    Multi tenancy in Spring MVC

    One of our clients aimed to replace old, often DOS based, point of sale systems with a cloud based, SaaS modeled solution. At Bright Inventions we have developed all required components including AWS based back-end processing requests originating from multiple clients. Each business that uses the SaaS point of sale can be considered a tenant in a multi-tenant environment. There many aspects involved when developing multi-tenant application with data isolation and partitioning being the most discussed topic. However, today I would like to focus on computational and resource isolation aspect.

  • Request timeouts in Spring MVC

    28 November 2017 spring, mvc, spring-boot, request, and timeout

    Request timeouts in Spring MVC

    As we saw previously, we only have limited options to configure maximum time a request processing can take in Spring MVC. In this post I will show how to enforce such timeout through a custom Servlet Filter.

  • Request timeouts in Spring MVC

    21 November 2017 spring, mvc, spring-boot, thread-pool, and timeout

    Request timeouts in Spring MVC

    Last time we reviewed how to configure HTTP client timeouts. This time let us focus on the other side of the HTTP request i.e. server. There is pretty much always a thread pool involved when we write a Spring MVC application. The thread pool configuration will vary depending on particular servlet container (Tomcat, Undertow, Jetty) so we have to watch out for subtle differences. However, most if not all of them will use a thread pool with fixed maximum size. As we already know, a pool of resources might get exhausted. In particular, a thread pool is more likely to get exhausted if we do not control timeouts diligently.

  • HTTP client timeouts

    05 November 2017 http, timeout, network, rest, and api

    HTTP client timeouts

    We have already touched upon the importance of timeouts and described most important related JDBC knobs. The next aspect of timeouts I would like to focus on is using API clients. Specifically HTTP clients which are by far the most popular. We will review couple of popular HTTP client libraries and their configuration regarding timeouts.

  • Database timeouts

    31 October 2017 database, timeout, jdbc, query, and transaction

    Database timeouts

    Last time I have outlined the importance of timeouts. Without a carefully considered timeouts our application can become unresponsive easily. In this post I will focus on configuring various timeouts related to interaction with database. I am going to focus specifically on relational databases. The principles and practices however can be applied equally well to other types of databases.

  • The importance of timeouts

    23 October 2017 server, request, timeout, query, resiliency, spring, and boot

    Timeouts are not an exciting thing to talk about. They do not add immediately perceivable value. They are difficult to guess get right and force one to consider problems that are hard to solve. In fact, in my experience, the timeout is only ever considered when our software stops working or is about to. That is an enormous shame since, in my opinion, carefully applied timeouts can vastly improve software resiliency.

  • How to clear database in Spring Boot tests?

    13 October 2017 tests, spring, boot, database, and kotlin

    Nowadays using a production like database in unit1 tests is a common practice. Calling a real database can increase our confidence that a tested code actually works. Having said that a database, by its very nature, brings external state into a test that will affect its behavior, hence we need to pay special attention to prepare the test execution. There are couple of ways to handle the database state in tests and I’m going to describe an approach I like most.

  • Simple Config Sections 1.2 released

    25 December 2015 .net and .net

    About a week ago I’ve released another version of SimpleConfigSections. It’s marked 1.2.0 and you can install it through Install-Package SimpleConfigSections.