SQS to Pub/Sub Conversion using Cloud Sidecar

This is the second entry in a series (prior entry here) explaining how you can use Cloud Sidecar to take your software and run it multiple clouds with very little code change. What is Cloud Sidecar? It is an application that runs next to your software as a sidecar, intercepts cloud API requests, and converts the API calls to a different cloud provider without your software noticing. Since it intercepts API calls, it works for virtually any software or language. In this entry I will show you how to convert your software from using Amazon SQS to Google Pub/Sub

How To Do It

Make sure you have Golang installed, preferably 1.15.x or higher

Clone Cloud Sidecar from github

Run ./build.sh to build the binary for your target architecture

Create a config file named config.yaml. It should look something like

aws_configs:
  sqs:
    service_type: "sqs"
    port: 3460
    aws_destination_config:
      name: "example"
      access_key_id: "bleh"
      secret_access_key: "bleh"
    gcp_destination_config:
      name: "example"
      key_file_location: "/location/to/gcp/creds.json"
      project: "project name here"
      pub_sub_config:
        read_timeout: "10s"

Alter your application code to connect to connect to localhost on port 3460. Here are examples on how to do it in Python and Java

Python

import boto3
import os

client = boto3.resource(
    "sqs",
    region_name="us-east",
    endpoint_url='http://localhost:3460',
)
queue_url = "https://sqs.us-east-1.amazonaws.com/someid/queue-url"

response = sqs.receive_message(
    QueueUrl=queue_url,
    AttributeNames=[
        'SentTimestamp'
    ],
    MaxNumberOfMessages=1,
    MessageAttributeNames=[
        'All'
    ],
    VisibilityTimeout=30,
    WaitTimeSeconds=5
)
message = response['Messages'][0]

Java

import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
import com.amazonaws.services.sqs.model.AmazonSQSException;
import com.amazonaws.services.sqs.model.SendMessageBatchRequest;


final AmazonSQS sqs = AmazonSQSClientBuilder
    .standard()
    .withEndpointConfiguration(new EndpointConfiguration("http://localhost:3460", Regions.US_EAST_1.getName))
    .build()

List messages = sqs.receiveMessage(queueUrl).getMessages();

Start up Cloud Sidecar by running ./cloudsidecar --config=config.yaml

AND NOW YOU ARE TALKING TO PUB/SUB!!!

This was a very simple example, but can easily be extended to more complex applications, use Kubernetes, etc… If you have any questions feel free to reach out to me at larry@cloudsidecar.com or drop a comment in this blog entry.

Advertisement

S3 to GCS Conversion using Cloud Sidecar

This is an entry in a series explaining how you can use Cloud Sidecar to take your software and run it multiple clouds with very little code change. What is Cloud Sidecar? It is an application that runs next to your software as a sidecar, intercepts cloud API requests, and converts the API calls to a different cloud provider without your software noticing. Since it intercepts API calls, it works for virtually any software or language. In this entry I will show you how to convert your software from using Amazon S3 to Google GCS (Google Cloud Storage).

How To Do It

Make sure you have Golang installed, preferably 1.15.x or higher

Clone Cloud Sidecar from github

Run ./build.sh to build the binary for your target architecture

Create a config file named config.yaml. It should look something like

aws_configs:
  main_s3:
    service_type: "s3"
    port: 3450
    aws_destination_config:
      name: "example"
      access_key_id: "bleh" # place aws access key here
      secret_access_key: "bleh" # place aws secret key here
    gcp_destination_config:
      name: "example"
      key_file_location: "/location/to/gcp/creds.json" # place path to gcp creds here
      gcs_config:
        multipart_db_directory: "/tmp/"

Alter your application code to connect to connect to localhost on port 3450. Here are examples on how to do it in Python and Java

Python

import boto3
import os

client = boto3.resource(
    "s3",
    region_name="us-east",
    endpoint_url='http://localhost:3450',
    use_ssl=False,
)

client.Bucket("cool-bucket").put_object(
    Key = "/my-file", 
    Body = open("/home/someuser/sourcefile", 'rb')
)

Java

import com.amazonaws.AmazonServiceException;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;

final AmazonS3 s3 = AmazonS3ClientBuilder
    .standard()
    .withPathStyleAccessEnabled(true)
    .withEndpointConfiguration(new EndpointConfiguration("http://localhost:3450", Regions.US_EAST_1.getName))
    .build()
s3.putObject(bucket_name, key_name, new File(file_path));

Start up Cloud Sidecar by running ./cloudsidecar --config=config.yaml

And now your software is talking to GCS!!!

This was a very simple example, but can easily be extended to more complex applications, use Kubernetes, etc… If you have any questions feel free to reach out to me at larry@cloudsidecar.com or drop a comment in this blog entry.

Interviewing As A Senior Engineer

After almost seven years at my most recent job, I decided it was time to move on.  I have  over ten years experience and the past few years I’ve had a very senior role with the fancy title of “Principal Engineer” (whether I deserved that title is a different story).  There are many stories about how to get a job after going to a boot camp or after graduating college, but nothing about experienced engineers switching jobs.  Here are some tips and observations from my quest for a new job.

  • There is a lot of demand – Many companies are looking for or claiming that they are looking for senior engineers.  A lot of it is noise but a lot of it is good.  Though, don’t get cocky.
  • Update your resume –   I’ve definitely been asked about random aspects of my resume.   Remove old languages you haven’t used in a while (Perl?), projects you worked on many years ago, and anything you can’t go into with great detail.   Don’t include projects you cannot explain in deep technical detail or any technologies that you barely used because someone might ask you about it and you will look pretty dumb.
  • Some head hunters are decent –   I worked a little bit with bamboo talent and they were actually fantastic.  But most still are used car salespeople trying to sell you bad goods.
  • Referrals – Referrals will help you get your foot in the door.  You might even be able to skip one interview round.  However, having a friend at a company is not a shoo-in to getting a job, so prepare for those interviews!  Though, if you are good friends with the CTO or CEO or something you can probably get the job without interviewing (or even being right for the job), so kudos to you if you have such an awesome connection.
  • Algorithm questions – Whether or not you agree with their value, algorithm questions are still a big part of interviewing.  While I was programming or reviewing code about 75% of my time at work, I rarely had to implement any data structures myself or determine the complexity of an algorithm.  I practiced solving algorithm questions for a few weeks before interviewing by using LeetCode.com. There are plenty of sites like this, but your best bet is to do as many questions as you can (focus on trees).  After you solve a problem, look at the “best” answer.  Most problems have a short and elegant solution.  Knowing, understanding, and being able to recall these elegant answers will make your interview much better.   So revisit questions and make sure you can give an elegant solution.
  • Memory vs performance – When asked an algorithm question, there are usually multiple solutions depending on whether you want to save memory.  Don’t assume anything, ask the interviewer.
  • Practice interview – Interviewing is tough and you will probably fail your first (or first few) interviews no matter how smart you are.  Set up a few interviews with companies you are not very interested in before you interview at places you are interested in.  This way you can get good feedback and practice.
  • Pair programming – It’s common now for companies to use some browser-based IDE when conducting interviews.  I like these questions because there is an actual compiler and programming on a computer is a lot more familiar than writing code on a whiteboard.  Sometimes there is a pairing aspect to this exercise, so get used to that.
  • Know the role – Know what role you are interviewing for and the team.  If the role doesn’t sound interesting, it is probably not interesting.
  • Perks aren’t everything – If the company sounds silly, then it is probably silly.   Don’t let a smart team or tough interview fool you.  Don’t work at a place just because they have great perks.  It’s also kind of insane how complicated some interviews are for uninteresting mundane simple jobs.
  • Titles vary – Companies define titles very differently, so be prepared for that.  Just because you were a VP at your old job (if you are at a bank…) doesn’t mean you will be a VP at any other company.  It’s not a bad thing, just prepare yourself.
  • Negotiate – If you are senior and good, you have leverage to negotiate.  So do it.

GOOD LUCK!

San Francisco Bubble

The other week I spent some time visiting friends in San Francisco.  I’ve been going to SF on and off every year for about ten years now.  However on this journey, the weirdness of the city appeared to be at a whole new level.  I believe that San Francisco is in a financial and social bubble separate from the real world.

  1. Everything is too expensive.  I’m from New York, I expect the fine things in life to be expensive.  But EVERYTHING in SF is expensive.  Museums are $35, crappy local IPAs are 15$, tiny “artisanal” salads are 16$, etc..  Rent is the highest in the country.  How is any of this sustainable?
  2. There are thousands of dumb startups.  My friend let me work a little in his cowork space.  This office had at least a dozen startups in it.  As I walked to get coffee with another friend (YES I HAVE TWO FRIENDS) ten blocks away, I passed by dozens of these cowork spaces each with dozens of dumb startups.  A company to “disrupt the banana hammock ordering process” cannot possibly do well yet someone invested  money into it and it is paying employees.  Sure, some startups solve legitimate problems and have a lot of talent and chance for success, but a majority of them are silly.
  3. People are spoiled.  A friend of mine takes an uber to and from work every day, and apparently that is fairly common.  New apartment buildings have features like bringing your groceries up to your apartment for you.  Every food item has to be locally sourced and organic, which seems more important than taste and quality.  Engineers are particularly spoiled.  They can take an arbitrary sabbatical from work, they cannot be told no or reprimanded, and they make so much money that they can just take random breaks from employment to chill.
  4. There cannot be these many quality engineers.  I know SF has a lot of quality engineers and attracts a lot of talent.  But with the number of startups and dumb startups there must be a lot of not-so-great engineers filling these roles.  This reminds me of the first dot com bubble where people with degrees from devry were joining companies and making big salaries (sounds very similar to boot camps).  I’m sure some people from these programs become quality engineers.  However, that requires great mentorship and at the job learning.  I feel that the majority of them do not receive this.  You learn very different things working for a startup with 50 occasional users vs a startup at scale.

It feels to me that VCs and angel investors are pumping money into SF.  This money helps fund many tiny crappy startups.  The many startups pay large wages to engineers of widely varying talent.  They get spoiled and do / buy stupid shit.  This leads to SF being expensive and just weird.  I’m not saying I would never move there, just stating my observations.

Good Luck,
-Larry

Framework Exceptions

There is a bad trend with some popular frameworks.  Every now and then your code will throw an exception.  Typically, you look through the stack trace and fix the bug.  But on occasion  the exception is from within the framework.  You see absolutely nothing in the stack trace that refers to any of your code.  But how is that possible?  Clearly it is some code that you wrote that is causing the exception but your code is completely absent from the stack trace.  How are you supposed to debug this?  Of course you can step through your code or back out recent changes, but that is a complete pain in the rear.  Framework writers and contributors.  Please, please, please prioritize preventing these types of magical exceptions.Good Luck,
-Larry

Error Messages

An often overlooked aspect when developing software is error messaging.  If you are building a backend to be consumed programmatically, you want there to be a code or some easy way to parse an error without having to actually match an entire error message.  For front ends, you need to have a nice centralized place where error message show up.  The messages themselves have to actually make sense to the user so that they can know what to do next.  Shortcuts taken during development like generic error messages can lead to a very confusing user experience.

Good Luck,
-Larry

Test Please

Testing is a very contentious subject.  Some people hate it with a vengeance, thinking it is a waste of time for engineers to write and conduct tests.  Others think of it as a religious requirement, TDD (test driven design) is their Messiah.  There are dozens of different test frameworks per stack and several types of testing to conduct.  With that in mind, imagine how hard it is to effectively test software.

Pardon me being so opinionated, but you need automated unit testing.  I am not the greatest at writing unit tests and having enough coverage (as anyone who has worked with me knows) but there are obvious benefits.  The definition of testing is  … to make sure something works.  So why would you not want to make sure something works?  Writing tests also makes you think through different edge cases that you probably would not have normally during development.  It helps prevent future code changes from breaking working functionality, AKA regression testing.  Regression testing is probably my favourite reason for writing tests because it is so easy to break a system when trying to add a new feature, especially if you didn’t write the original code.  Some say that tests document the code, I don’t really buy that because I’ve never looked at tests to understand code but I am not everyone.

While automated testing is great, sometimes I feel like it is a crutch.  Just because you wrote some unit tests doesn’t mean that your code will work as planned.  I find that people rarely actually try out the software they write as an end user.  You add a new endpoint or field to your API you should actually try curling it.  Or maybe you add a new zoom feature to your website, you should try zooming in and out.  Try out a real user flow to make sure that not only the specific feature you built work but it works as the users will use it.  And if you can automate integration and behavioral tests you definitely should in order to prevent regressions.

Write tests, I know it is a pain in the butt however it is worth it in the long run.  You don’t want your code breaking at 3am costing the company money.  Some tests are better than none.  Lots of tests are better than some.  But make sure you actually try out your software.  Be a client, you might learn something.

Good Luck,
-Larry

Boarding a Plane

Boarding a plane is such a weird experience.  I was recently on a flight just noticing the mayhem going on.  In the end it all works out, but it is so odd.  People congregate around boarding lines regardless of whether they are to board first or last.  Some people randomly stand between the plane and other people (I guess “cutting”, but there is no real line) when they are in the last zone to board. But the weirdest part of boarding is the “pre-boarding.”

Pre-boarding is meant for the elderly, those with disabilities, people with tiny kids, and generally people that need more time to board the plane.  When they called pre-boarding on my flight, a blind man got on line.  That makes sense, that’s a disability.  A very elderly man shuffled to get on line.  I completely understand him being on that line too.  A middle aged lady got on the line, and while it’s not obvious why she needs to pre-board I accept it because even if you appear in good shape it is hard to do certain things as you get older.  A lady holding a tiny child was next on line, and it has to be damn hard to get on a plane with a baby in your arms.  Then two ladies with a teenage girl got on the plane.  They seemed healthy enough, no good reason I could see for them getting on that line.  Next on line was two guys about my age who appeared nimble, too nimble.  I cannot imagine what would cause them to need to pre-board.

I don’t buy that all those people need to pre-board.  I am making huge presumptions, but some of those people that got on line did not look like they needed extra time to board the plane.  When we landed, they announced that people who need extra time to get off the plane should let other passengers off first.  Surprisingly, the two ladies with the teenage girl and the two nimble guys got off with everyone else.  I guess they needed extra time to board but not to get off the plane?

I want to do an experiment and just get on that line.  See what happens.  I have a gimpy knee and sometimes sore back.

Good Luck,
-Larry

 

Gym Tales Part I

My coworker Ben requested more gym blog entries.  He said he has had enough of the tech and startup BS.  So here it is Ben, a gym story from my past.

It was about ’09 and since I lived by Columbus Circle I was a member of Gold’s gym in Hell’s Kitchen.  It was a fairly grimy gym, but it had all of the weights, racks, and cardio equipment that I needed.  The clientele was eclectic (unfortunately I never saw Daredevil or Jane there).  I like doing dumbbell benchpress instead of barbell because of the increased range of motion and the fact that you don’t need a spot when you use dumbbells, you just drop them.  I was between my second and third set when I stepped
away to get a drink of water.  I came back and there was a giant, beastly man now in the bench next to mine pressing the 130s.  He was one of those guys with a fanny pack for
no good reason and obscenely large veins popping out of his neck.  He kind of reminded me of bear-pig-man.  I had never seen a person use the 130s and I was afraid
that he would drop them on my feet so I stood back and let him do his thing.  He must have noticed me and figured I was watching him.  When he finished I went to do my set of 100s  (I was stronger back then, now my last set is 90s :/).  After I completed my set he said something like “nice set” and I just grunted.  Why was this guy talking to me?  Who talks
to strangers at the gym?

I went to get a drink of water before going onto the next exercise.  As I was drinking from the water fountain I noticed the room got dark.  There was a very large shadow being
cast over me.  In my head I wondered “oh crap, is it that giant dood from before?  Why did he follow me?”  When I finished drinking I looked over and realized it was him!  Quickly
I freaked out.  “Why did he follow me?  Did he think I was into him?  Does he want to sell my steroids?  Is he after my vital organs?  What happens when I say no?  Will he rip off my arm and beat me with it?.”  He said to me “Hey can I talk to you for a second over here?” as he motioned to some spot away from the water fountain.

I reluctantly followed him a few yards away.  I figured my life was over.  I lived a solid enough life.  I saw Europe, it was okay.  He starts off “Hey buddy.  I saw you doing bench press.  You’re doing a good job and have a nice upper body.  But there is something important I have to tell you.  Your legs are too skinny.  You really need to start working your calves more.  Like do calf exercises every day.”  I must have looked scared as hell because he then said “Oh ladies love strong calves.  My girlfriend really loves my calves.”  I responded with something like “oh thanks, uh, I will try that.”  He then said “No I am serious, you really need to do these exercises.  If you want I can show you.”  I politely declined and scurried away.

I’m not really sure the purpose of this story, but I am glad I didn’t anger the unruly giant.  It also reminded me of an Entourage episode where Drama had a complex about having small calves and wanted implants.  My finance brings up my small calves only once a month, which I can live with.

Good Luck,
-Larry

Being Exceptionally Exceptional

Recently at work we had a founders award to reward individuals that have made a “founders level contribution” to the company.  This award is not merely for top performers but for people who make such a great impact on the company that the company would not be the same without them.  These are people who perhaps prevented the company from failure and/or are instrumental in the overall success.  In a world of “rock-star developers” “ninjas” and “linchpins”, what does it take to be exceptionally exceptional?  I am going to be brutally honest with these points.  These points will both go over what it takes to be instrumental in a company and what it takes to have people recognize it.

  1. Going way beyond your role – Even if your role includes a lot of responsibilities, you need to go above and beyond your role.  Constantly fix and improve everything you can get your hands on.  Go out of your way to make clients happy and get new clients.
  2. Work many hours – I think the sad truth is you cannot work a general work day (8 hours 5 days a week?) and be exceptionally exceptional.  If you come in at 9 and leave at 5 every day on the dot, you are not going to be in this category.  I’m sorry.  There is just not enough hours in the day to do your role and to go above and beyond.  Maybe if you take some performance enhancing drugs you can do it, but I doubt that is a good option.
  3. Push hard upwards – I am not sure a better way to phrase this, but you need to push on your managers, their managers, and up the chain for more responsibilities and to improve what you see.  Not only will you get more visibility,  you will get placed on projects that are more important and have more visibility themselves. And the muckedy mucks need to know how hard you work and that you are hungry.
  4. Be lucky – No matter how hard you work, luck is very important.  Sometimes being at the right place at the right time allows you to be staffed on a highly important project.  Or maybe you happen to be chatting with someone and get a brilliant idea on how to improve the company.  Or you happen to have a college roommate that works at a company that can be an important client or partner.
  5. Be on the right team – This may be a controversial statement, but being on the right team increases your chances of being viewed as exceptional.  For example, if you work at social startup XYZ and you are in charge of the team building the now highly successful mobile app to compliment the web site, you have a much higher chance of being viewed as exceptional than if you worked on the back-end team.  On the back-end you would have to invent something like kafka to be viewed as exceptional.  Imagine what a person on the client client services or a developer evangelist team has to do to be viewed as having a massive impact on the company.  To be fair, a technical operations individual received the award at my company but that is because he has spent many a night holding together systems with his bare hands.
  6. Make allies and not enemies – For both the perception aspect and having access to great projects, you need to have a lot of allies.  I know playing politics sucks, but it definitely helps.  It is probably more important for the perception piece.
  7. Have a good manager – This definitely will help you get good projects.

There you have it, my thoughts on how to be “exceptionally exceptional.”  If your goal is to have a great and important impact on the company, these points might help you.  Though you have to wonder, is the juice worth the squeeze?

Good Luck,
-Larry