Skip to content

Instantly share code, notes, and snippets.

@fragoulis
Last active April 2, 2024 07:31
Show Gist options
  • Save fragoulis/fe6de773d555dbf0f9c18289d21d802c to your computer and use it in GitHub Desktop.
Save fragoulis/fe6de773d555dbf0f9c18289d21d802c to your computer and use it in GitHub Desktop.
Interview

The interview

  • introductions - 5 minutes
  • discussion - 45 minutes
  • q&a - 10 mintues

The goal

  • to build a team of go developers that will work closely with the biostrand development team to develop their product

The product

  • a web app that sits on top of apis written in go
  • the app is a the tool data scientists use to run predictions of various ai models as well as perform complex search to retrieve information from various data sources such as medical publications etc.
  • the core business is related to the biomedical sector
  • the product is in its infancy and will allows to get creative

Interview A - Building a wev app

Open ended discussion.

Topic

We want url shortener (tinyurl clone) web app that exposes a rest api. There is no need for UI.

The requirements are:

  1. A customer sends a request with a url to minify POST /api/v1/url
  2. The app responds with the short url

  1. A user sends a request to GET /:id
  2. The app responds with the 301/302 and the location header set to the original url.

(optinal)

  1. A user sends a request GET /api/v1/url
  2. The app responds with the long url to redirect

https://media.licdn.com/dms/image/D4E22AQFHoiO_KPCmxQ/feedshare-shrink_800/0/1711169061818?e=1715212800&v=beta&t=8itHv86y7NdaOX0mpPfXwBDzpMKmXhH0zDlcJo-80XY

The above urls are restful, but could also be RPCs (ie. POST /api/url/shorten , no strongs commitments.

We expect the candidate to ask questions about the app:

  • the design
  • the requirements,
  • the traffic volume,
  • the request and responses etc.

Coding/Architecture

We expect the candidate to talk about the:

  • domain logic, modeling (ask for pseudocode)
  • layered architecture (api, domain, repository etc)
  • data(base) modeling (sql knowledge as well)
  • the hashing function (hashing the id vs the long url, size of the id, collissions, encoding methods, md5/crc/sha1, base62)
  • response codes
  • error handling and recovery

We expect the candidate to talk about the business logic and write a method in pseudocode that expresses that.

An example of a method that uses the long url as input to create the short url:

def createShortUrl(longUrl)
  record = db.find(longUrl)
  if record
    spawn cache.set(record.shortUrl, longUrl)
    return record.shortUrl
    
  shortUrl = hash(longUrl)
  
  if db.exists?(shortUrL)
    // already exists, means collision
    // retry with predefined string
  else
    db.save(longUrl, shortUrl)
  
  spawn cache.set(shortUrl, longUrl)
  
  return shortUrl

An example of a method that uses a unique id generator to create the short url (better for collisions):

def createShortUrl(longUrl)
  record = db.find(longUrl)
  if record
    spawn cache.set(record.shortUrl, longUrl)
    return record.shortUrl
  
  id = createID()
  shortUrl = createFromID(id)
  db.save(id, longUrl, shortUrl)
  
  spawn cache.set(shortUrl, longUrl)
  
  return shortUrl

An example of retrieve method:

def findLongUrl(shortUrl)
  longUrl = cache.get(shortUrl)
  if longUrl
    return longUrl
   
  record = db.find(shortUrl)
  if record
    spawn cache.set(shortUrl, record.longUrl)
    return record.longUrl
  
  return null

Database/Persistent storage

  • database (rdbms, redis, nosql or other (memory?))
  • reliability
  • caching

Deployment

  • binary
  • rsync
  • containers
  • gitops
  • vm
  • k8s
  • cloud

System Design

  • scaling (load balancing, proxying, routing, microservices, vertical, horizontal)
  • rate limiting
  • caching
  • reliability

Documentation / Communication

We expect the candidate to create

  • a visual representation of the setup/architecture
  • ideally a flowchart for the decision making
  • (and a sequence diagram for the reqest flow?)

https://codeshare.io/XLOYVn

https://excalidraw.com/#room=6f142069f272b9b7f00d,Smxh0NAt1q8JZb4D0dsBvw

Interview B - Questions

Targeted to more junior devs.

Optionally start with some points from their CV. They should be able to explain:

  • what they did
  • why they did it in that way
  • how they did it
  • why thet did it in general from a business perspective

HTTP

What happens when you type in your browser "google.com"

Expect the candidate to talk about:

  • DNS
  • browser being the client
  • OSI
  • Networking (ip4/ip6, routing)
  • Server/app responding to a get request to the home path
  • Any form of possible app routing
  • Http request/response
  • The browser parsing the response body and rendering the page using html/css
  • Non-happy path endings (timeouts, 4**, 5** etc)

REST

What is rest? Can you give an example of using rest to manage a for example a user?

DATABASES

What is a relation database? What are the key characteristics? ...

Database Migrations

How would you handle the following scenario:

You have an app and there is a requirement for a new feature. The new feature, except for the code change, just so happens it also requires a change in the database, for example a new column needs to be added in a table or a column needs to be removed.

What would your actions be for each of those cases, in order to deploy your new feature without downtime.

Containers

What is a container? What is kubernetes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment