Posts

Showing posts with the label api

Load test your API with Vegeta

Image
Load test your API with Vegeta Vegeta is a open source HTTP load testing tool. Today I’ll demonstrate how quickly and easily we can load test our API endpoint using it in three parts: Get Vegeta Setup a target file Generate reports 1. Get Vegeta Vegeta binaries are available on GitHub Releases . For Windows, all we need to do is to get the Windows executable and unzip it for example under C:\vegeta . The vegeta.exe is the executable we will be using. To make sure it works as expected, we can display the usage guide by execute vegeta.exe without any arguments. > vegeta.exe Usage: vegeta [global flags] <command> [command flags] global flags: -cpus int Number of CPUs to use (default 4) -profile string Enable profiling of [cpu, heap] -version Print version and exit attack command: -body string Requests body file -cert string ... The main concept of Vegeta are the targets . A target represents an endpoint which will be load...

ApiController attribute in ASP NET Core 2.1

ApiController attribute in ASP NET Core 2.1 ASP NET Core 2.1 brings a set a enhacements for Web API development, Web API being a service accessible via HTTP and returning result in Json format. Those enhancements aim to simplify the composition of those APIs and also remove unecessary functionalities. Today we will explore those enhancements in five parts ControllerBase and ApiController Automatic model validation Inferred model binding ActionResult<T> 1. ControllerBase and ApiController Prior everything, we should set the compatibility version of ASP NET Core by using the .SetCompatibilityVersion . services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); In the past, we used to inherit from Controller which was providing functions to return different HTTP status code results together with optional data like Ok(...) or Json(...) , but it was also used to display Razor views like View(...) or PartialView(...) . Starting from 2.1, it is now recomm...